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

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

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
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

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.

Build reliable WinCC VBScript projects

Join practical online, classroom or corporate training.

Request Course Details
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