How to Read and Write Tag Values in WinCC SCADA Using VBScript

Published on Jun04, 2025 | Category: wincc
Share this article:

VBScript is a lightweight and easy-to-use scripting language supported by WinCC SCADA for implementing custom automation logic, event handling, data manipulation, and UI interaction within HMI projects. WinCC enables engineers to define actions, respond to events, create classes, and manage sequences using VBScript for both runtime and development purposes. In Siemens WinCC SCADA, a tag acts as a variable used to store and transfer values such as analog inputs, digital signals, process statuses, alarm states, and communication data from PLCs or internal HMI logic. The ability to read and write values to tags is fundamental for real-time monitoring, control operations, and interactive operator interfaces in industrial automation systems. This article provides a step-by-step guide on how to read and write tag values in WinCC using VBScript. Whether you're working with analog/digital variables or internal/external process values, mastering tag scripting enables enhanced control and flexibility in HMI development. If you're already familiar with WinCC HMI and its VBScript environment, this guide will help you deepen your understanding of tag-based scripting and implement robust logic for your automation tasks.

Define Tags in WinCC SCADA Tag Manager

In the WinCC Tag Manager, you can define various types of tags such as inputs, outputs, start/stop signals, alarms, and process values. Each tag is configured with a specific data type (e.g., Boolean, Integer, Real) based on the application requirements. These tags can then be accessed and manipulated using VBScript for automation and control purposes within the SCADA.

img/wincc-scada-read-write-tag/define-tags-in-wincc-scada-tag-manager.webp

Add Components and Set Tags in WinCC SCADA

Open the Graphics Designer in WinCC SCADA and add Input/Output fields to your screen. Assign appropriate tags to these fields for reading or writing data. In this example, we use two Input/Output fields—one for input and one for output—each linked to their respective tags. Additionally, add a button component to the screen. This button will be used to trigger the VBScript. To do this, go to the button’s Mouse Click event properties and add the script (as shown in the example below). After applying the script, test your program to observe the interaction between the HMI and tag values.

img/wincc-scada-read-write-tag/add-components-and-set-tags-in-wincc-scada.webp

How to Read Tag Value of WinCC SCADA Using VBScript

Reading a tag value is very important in WinCC SCADA. To read a tag value, use the following steps:

Below is an example demonstrating how to read a tag value:

img/wincc-scada-read-write-tag/how to read tag value of wincc scada using vb script.webp

ad this script to a button mouse click event.


How to Write Tag Value Using VBScript in WinCC SCADA

Writing a value to a tag in WinCC SCADA means updating or moving a new value into the tag to control or influence the connected PLC or HMI process variable in real time. This is essential for automation control, operator inputs, and dynamic process adjustments.

Below is an example demonstrating how to write a value to a tag using VBScript:

img/wincc-scada-read-write-tag/how-to-write-tag-value-using-vbscript.webp

This VBScript subroutine OnClick executes when an event (such as a button click) occurs. It first creates a variable to reference the WinCC tag named "input". Then, it defines a value (60) to write to this tag. Using the Write method, it updates the tag with this value. Finally, it displays a message box confirming the value has been written.