<!-- Softwell WinCC VBScript 20-Part Tutorial · Blog 09 · updated 2026-08-29 --> WinCC VBScript Operator Input Validation and Command Gating | Softwell
WinCC VBScript · Operator Interaction · Practical Guide

WinCC VBScript Operator Input Validation and Command Gating

Design safer operator interactions with range validation, confirmation, authorization-aware HMI controls and clear PLC command boundaries.

Guide Overview

Supporting WinCC VBS GuideStudy time: 60 minutesDifficulty: Intermediate

What You Will Design

  • Numeric input range and type validation
  • Confirmation and authorization-aware HMI behavior
  • PLC request, acknowledgment and rejection workflow

Learning Foundation: Safe Operator Interaction

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

Conversions, decision logic, tag writes and error handling.

Core concept

Operator input is untrusted data. Validate format, range and process context before writing setpoints or command requests. PLC-side interlocks remain authoritative.

SQF practical connection

Validate furnace number, temperature/CP setpoints and start/stop requests before writing to WinCC tags.

Expected competency

Implement InputBox validation, range checks, confirmations and HMI command gating without bypassing PLC permissives.

WinCC VBScript Operator Input Validation and Command Gating — ArchitectureCode-rendered HTML/CSS architecture; no image file required
Operator Input

Receive entered value/request

InputBox
Validate Type

Reject invalid text

IsNumeric
Validate Range

Apply engineering bounds

If Value < Min
Confirm / Gate

Check intent/context

MsgBox / mode
Tag Request

Write only approved request

HMIRuntime.Tags(...).Write

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.

WinCC VBScript operator input validation and command gating

This practical guide explains how to validate operator-entered values and control HMI command availability without moving equipment protection or safety logic out of the PLC.

Control boundary: HMI validation improves usability and reduces accidental input. The PLC or safety system must independently enforce modes, limits, permissives, interlocks and safe-state behavior.

1. Separate HMI validation from PLC command authorization

An HMI can check whether a value looks reasonable and explain why a button is unavailable. It cannot be the only layer preventing an unsafe command. Treat every HMI write as an external request that the PLC must validate.

LayerRecommended responsibility
WinCC screenInput format, engineering range, confirmation and operator feedback
WinCC User AdministrationRole-based access to approved HMI actions
PLC programMode, sequence, permissive, interlock and command acceptance
Safety systemSafety functions and risk-reduction measures

2. Validate numeric operator input before writing a tag

Read the proposed input, confirm it is numeric, convert it explicitly and reject values outside the approved engineering range.

Function ValidateSetpoint(ByVal proposedValue, ByVal lowLimit, ByVal highLimit)
    ValidateSetpoint = False
    If Not IsNumeric(proposedValue) Then Exit Function

    Dim value
    value = CDbl(proposedValue)
    If value < CDbl(lowLimit) Or value > CDbl(highLimit) Then Exit Function

    ValidateSetpoint = True
End Function

Easy TestEasy Test 1 — InputBox + MsgBox

A self-contained function test using the same setpoint/actual-value pattern as the SQF project.

Function TestIsOK(ByVal SetValue, ByVal ActualValue)
    TestIsOK = (ActualValue >= SetValue)
End Function

Dim SP, PV
SP = CDbl(InputBox("Enter Setpoint", "Easy Test 1 — InputBox + MsgBox", "850"))
PV = CDbl(InputBox("Enter Actual Value", "Easy Test 1 — InputBox + MsgBox", "825"))

MsgBox "Setpoint = " & SP & vbCrLf & _
       "Actual = " & PV & vbCrLf & _
       "Function Result = " & TestIsOK(SP, PV), _
       vbInformation, "Function Quick Test"

Display the engineering unit and permitted range next to the entry field. Do not silently clamp an operator value unless the approved functional specification explicitly requires it.

3. Write only after validation and confirmation

Sub WriteApprovedSetpoint(ByVal proposedValue)
    If Not ValidateSetpoint(proposedValue, 0, 100) Then
        HMIRuntime.Trace "Setpoint rejected: invalid range" & vbCrLf
        Exit Sub
    End If

    If MsgBox("Apply setpoint " & CStr(proposedValue) & " %?", _
              vbQuestion + vbYesNo, "Confirm setpoint") = vbYes Then
        HMIRuntime.Tags("HMI_Setpoint_Request").Write CDbl(proposedValue)
        HMIRuntime.Trace "Setpoint request submitted" & vbCrLf
    End If
End Sub

Easy TestEasy Test 2 — InputBox + MsgBox

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

Dim TestValue
TestValue = InputBox("Enter value to test for WinCC tag: HMI_Setpoint_Request", "Easy Test 2 — InputBox + MsgBox", "1")
If TestValue = "" Then
    MsgBox "Test cancelled.", vbInformation, "Tag Write Quick Test"
Else
    MsgBox "SIMULATION ONLY" & vbCrLf & _
           "Tag: HMI_Setpoint_Request" & 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

Confirmation is most useful for consequential or infrequent actions. Avoid interrupting routine operation with unnecessary dialogs.

4. Gate an HMI command from displayed operating state

A button may be disabled when the displayed machine mode or readiness state is unsuitable. This gives immediate feedback but remains separate from PLC acceptance.

Function CanRequestStart()
    Dim modeValue, readyValue
    modeValue = HMIRuntime.Tags("Machine_Mode").Read
    readyValue = HMIRuntime.Tags("Machine_Ready").Read

    CanRequestStart = (modeValue = 2 And readyValue = 1)
End Function

Easy TestEasy Test 3 — InputBox + MsgBox

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

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

Use explicit state values or documented constants. Avoid unexplained numeric values in production libraries.

5. Apply user authorization correctly

Configure permissions in WinCC User Administration and use the supported authorization dynamic or object-model method for the installed release. Test authorized, unauthorized, expired-session and logged-out states.

  • Show why the action is unavailable.
  • Log consequential command requests with user and timestamp where required.
  • Never treat a hidden button as a security boundary.

6. Use request and acknowledgment tags

For important commands, use a PLC handshake instead of assuming that a successful HMI write means the action occurred.

  1. WinCC writes a command request and optional request identifier.
  2. The PLC validates mode, permissives and interlocks.
  3. The PLC accepts or rejects the request.
  4. WinCC displays acknowledgment, rejection reason or timeout.

7. Test invalid, stale and unavailable states

TestExpected HMI behavior
Text entered in numeric fieldReject without writing
Value outside engineering rangeShow allowed range and preserve previous approved value
Communication unavailableDisable request and show connection state
User lacks permissionPrevent interaction and show authorization feedback
PLC rejects commandDisplay the returned reason or timeout state

8. Commissioning checklist

  • Document every command tag, unit, range and data type.
  • Confirm the PLC validates every HMI request independently.
  • Test boundary values, invalid text, communication loss and user-role changes.
  • Confirm scripts do not issue repeated writes from cyclic triggers.
  • Record approved behavior in the functional specification and backup.

Frequently asked questions

Is disabling a WinCC button an interlock?

No. It is operator-interface feedback. The PLC or safety system must enforce the actual interlock.

Should invalid input be automatically corrected?

Usually it should be rejected with a clear message. Automatic clamping can conceal an entry mistake unless it is explicitly required and documented.

Can VBScript check user permissions?

Yes, where supported by the installed WinCC object model. Prefer configured authorization dynamics and verify the exact API for the deployed release.

Get the WinCC VB Scripting syllabus

Request practical online, classroom or corporate training details.

SQF Running Project Lab · Blog 09

Validate ChargeNo before saving

Dim Charge
Charge = Trim(CStr(HMIRuntime.Tags("ChargeNo").Read))

If Charge = "" Then
    MsgBox "Charge Number is required."
    Exit Sub
End If

Easy TestEasy Test 4 — InputBox + MsgBox

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

Dim TestValue, ResultText
ResultText = ""
TestValue = InputBox("Enter simulated value for ChargeNo", "Easy Test 4 — InputBox + MsgBox", "TEST")
ResultText = ResultText & "ChargeNo = " & TestValue & vbCrLf
MsgBox ResultText & vbCrLf & "Now compare these values with the original HMIRuntime .Read example.", vbInformation, "Tag Read Quick Test"
Input validation protects both operator workflow and report quality.

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