<!-- Softwell WinCC VBScript 20-Part Tutorial · Blog 07 · updated 2026-08-29 --> WinCC VBScript: Read and Write HMI Tags
WinCC Explorer · VBScript · Practical Tutorial

Read and Write WinCC Tags with VBScript: HMIRuntime Guide

Read and write WinCC process tags using HMIRuntime, including Value, QualityCode, TimeStamp, LastError and safe PLC write practices.

Lab Overview

WinCC VBS Lab 1Estimated time: 60 minutesDifficulty: Beginner-Intermediate

Prerequisites / What You’ll Need

  • Backed-up WinCC Explorer test project
  • Graphics Designer and Global Script VBS access
  • Internal test tags and Runtime diagnostics

Learning Foundation: WinCC Runtime Tag Access

This page has one defined job in the WinCC VBScript learning path. Master this foundation before using the same concept inside larger SCADA, SQL Server and reporting scripts.

IntermediateWinCC Explorer / Classic WinCCSQF Running Project
Prerequisite

VBScript variables, conversion, conditions and reusable functions. Test first with internal tags.

Core concept

HMIRuntime.Tags is the bridge between VBScript and configured WinCC tags. Read, validate, act, then write only approved command/setpoint values.

SQF practical connection

Read SQF temperatures and statuses; write validated setpoints or internal command requests.

Expected competency

Use HMIRuntime.Tags().Read and .Write with conversion, validation and diagnostic checks.

Read and Write WinCC Tags with VBScript: HMIRuntime Guide — ArchitectureCode-rendered HTML/CSS architecture; no image file required
PLC / Internal Tag

Configured WinCC data point

Temp_Act
Tag Object

Resolve through Runtime

HMIRuntime.Tags("Temp_Act")
Read

Acquire current value

.Read
Validate / Logic

Apply engineering rules

CDbl / If
Write / Display

Send approved result

.Write Value

Complete WinCC VBScript Learning Path

Use Previous/Next for the recommended practical order, or open any topic below as a reference.

WinCC VB Scripting Training →
Easy Testing Method: Every main code example on this page is followed by a copy-ready InputBox + MsgBox test. Use the dialog version first to understand the result, then move to the original WinCC/SQL code. Database writes and equipment commands are previewed or simulated unless the original example is already intended as a lab action.

Read and Write WinCC Tags with VBScript: HMIRuntime Guide

This lab targets wincc vbscript read write tags with copy-ready examples, expected results and diagnostic guidance.

Safety: Test on internal tags or an approved simulation system. Do not bypass PLC permissives, interlocks, user authorization or plant change control.

1. Understand the WinCC Tag Object

HMIRuntime.Tags("TagName") returns a WinCC Runtime tag object. The object exposes the process value plus diagnostic properties such as QualityCode, TimeStamp, LastError and ErrorDescription. Keep a reference with Set when several properties are needed.

Dim processTag
Set processTag = HMIRuntime.Tags("Demo_Temperature")
processTag.Read
HMIRuntime.Trace "Value=" & CStr(processTag.Value)
Set processTag = Nothing

Easy TestEasy Test 1 — InputBox + MsgBox

Offline tag simulation: useful before connecting the participant PC to WinCC Runtime.

Dim TestValue, ResultText
ResultText = ""
TestValue = InputBox("Enter simulated value for Demo_Temperature", "Easy Test 1 — InputBox + MsgBox", "825.5")
ResultText = ResultText & "Demo_Temperature = " & TestValue & vbCrLf
MsgBox ResultText & vbCrLf & "Now compare these values with the original HMIRuntime .Read example.", vbInformation, "Tag Read Quick Test"

2. Read Value, Quality and Timestamp Together

Dim processTag
Set processTag = HMIRuntime.Tags("Demo_Temperature")
processTag.Read

HMIRuntime.Trace "Value=" & CStr(processTag.Value) & _
    ", Quality=" & CStr(processTag.QualityCode) & _
    ", Time=" & CStr(processTag.TimeStamp)

If processTag.LastError <> 0 Then
    HMIRuntime.Trace "Tag error: " & processTag.ErrorDescription
End If
Set processTag = Nothing

Easy TestEasy Test 2 — InputBox + MsgBox

Offline tag simulation: useful before connecting the participant PC to WinCC Runtime.

Dim TestValue, ResultText
ResultText = ""
TestValue = InputBox("Enter simulated value for Demo_Temperature", "Easy Test 2 — InputBox + MsgBox", "825.5")
ResultText = ResultText & "Demo_Temperature = " & TestValue & vbCrLf
MsgBox ResultText & vbCrLf & "Now compare these values with the original HMIRuntime .Read example.", vbInformation, "Tag Read Quick Test"
Expected result: Diagnostics display the value, quality code and timestamp returned by Runtime.

3. Validate a Value Before Writing

Dim setpointTag
Dim requestedSetpoint
requestedSetpoint = 650

If IsNumeric(requestedSetpoint) Then
    If CDbl(requestedSetpoint) >= 0 And CDbl(requestedSetpoint) <= 900 Then
        Set setpointTag = HMIRuntime.Tags("Demo_TempSetpoint")
        setpointTag.Write CDbl(requestedSetpoint)
        Set setpointTag = Nothing
    Else
        HMIRuntime.Trace "Rejected: setpoint outside 0..900"
    End If
End If

Easy TestEasy Test 3 — InputBox + MsgBox

Write is simulated to avoid accidental equipment commands during beginner testing.

Dim TestValue
TestValue = InputBox("Enter value to test for WinCC tag: Demo_TempSetpoint", "Easy Test 3 — InputBox + MsgBox", "1")
If TestValue = "" Then
    MsgBox "Test cancelled.", vbInformation, "Tag Write Quick Test"
Else
    MsgBox "SIMULATION ONLY" & vbCrLf & _
           "Tag: Demo_TempSetpoint" & vbCrLf & _
           "Value that would be written: " & TestValue & vbCrLf & vbCrLf & _
           "After checking interlocks, use the original .Write code above in Runtime.", _
           vbInformation, "Tag Write Quick Test"
End If

Use User Administration and PLC-side limits in addition to the script. The HMI validates the request; the PLC remains responsible for permissives, modes and equipment protection.

4. Read Multiple Tags Clearly

Create one object per tag, use descriptive names and release every reference. Avoid building tag names from unchecked operator text. Literal tag names are also easier for WinCC cross-reference tools to identify.

5. Tag Read/Write Troubleshooting

SymptomCheck
Value is emptyTag name, connection, data type and whether Read was called
Quality is badPLC state, channel diagnostics, address and network route
Write returns but process does not changeAuthorization, PLC mode, command handshake and interlocks

Hands-On Verification Lab

Hands-on
1

Prepare a controlled test

Create only the internal tags, folders or disposable database rows required by this tutorial.

The test scope is isolated and documented.
2

Run the smallest example

Execute one operation and inspect WinCC diagnostics before expanding the script.

The expected value, file, object or database result appears once.
3

Test a failure path

Use a safe backup copy to test an invalid tag, path or disposable input.

The script records a useful error and cleans up without an uncontrolled action.

Frequently Asked Questions

Should this WinCC VBScript be tested in production?

No. Use a backed-up training or staging project and follow the plant change-control process.

Which WinCC versions does the example target?

The examples target classic WinCC Explorer V7.x/V8.x. Verify object properties, action signatures and providers in the installed WinCC help.

How should Runtime failures be diagnosed?

Use scoped Err checks, WinCC object diagnostics and HMIRuntime.Trace while recording the exact station, trigger, tag and Runtime identity.

Get the WinCC VB Scripting syllabus

Share your details and a Softwell advisor will contact you with training options.

SQF Running Project Lab · Blog 07

Read SQF process tags and write SQL status

Dim TempSet, TempAct, FanStatus

TempSet = HMIRuntime.Tags("Temp_Set").Read
TempAct = HMIRuntime.Tags("Temp_Act").Read
FanStatus = HMIRuntime.Tags("Fan_Status").Read

If TempAct >= TempSet Then
    HMIRuntime.Tags("SQL_Status").Write "TEMP READY"
End If

Easy TestEasy Test 4 — InputBox + MsgBox

Write is simulated to avoid accidental equipment commands during beginner testing.

Dim TestValue
TestValue = InputBox("Enter value to test for WinCC tag: Temp_Set", "Easy Test 4 — InputBox + MsgBox", "1")
If TestValue = "" Then
    MsgBox "Test cancelled.", vbInformation, "Tag Write Quick Test"
Else
    MsgBox "SIMULATION ONLY" & vbCrLf & _
           "Tag: Temp_Set" & vbCrLf & _
           "Value that would be written: " & TestValue & vbCrLf & vbCrLf & _
           "After checking interlocks, use the original .Write code above in Runtime.", _
           vbInformation, "Tag Write Quick Test"
End If
This chapter is where the language learned in Blogs 02–06 meets the WinCC Runtime object model.

Build reliable WinCC VBScript projects

Join practical online, classroom or corporate training.

Request Course Details
WinCC VBScript Learning Path 2 of 10

Safe HMIRuntime tag access: engineering guide

Build reliable tag reads and writes with explicit validation, quality checks, trace messages and controlled operator commands.

Implementation and commissioning checklist

Practical completion outcome

A tested tag-access function that handles valid values, invalid input and unavailable tags predictably.

Safety boundary: Validate scripts on a backed-up WinCC training or staging project. PLC safety functions, permissives and interlocks must remain independent of HMI scripting.

Verified learning pathway

Discuss WinCC VB Scripting Training

Explore practical WinCC VBS, SCADA, SQL reporting and industrial automation training options.

Content reviewed: 4 August 2026

☎ Call WhatsApp ✉ Email Enquire Now