Learning Foundation: Reusable HMI Navigation
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.
Graphics object control, tag mapping and reusable procedures.
Navigation must preserve equipment context. Reusable popups/faceplates should receive approved identifiers rather than duplicate screen logic for each asset.
Open one reusable SQF equipment popup and pass SQF_No/equipment context for tags and commands.
Build maintainable picture changes, popups and reusable equipment views with explicit context mapping.
Operator selects asset
Store/validate identifier
Open picture/popup
Bind context to instance
Use mapped tags safely
Complete WinCC VBScript Learning Path
Use Previous/Next for the recommended practical order, or open any topic below as a reference.
WinCC VBScript screen navigation, faceplates and reusable instances
Learn how to open contextual detail views, pass approved equipment identity and reuse one screen design across several motors, pumps or valves.
1. Define the navigation architecture before scripting
Start with a screen map showing overview pictures, area displays, equipment details, modal dialogs and the path back to a known location. A script should implement this model rather than inventing navigation independently inside every button.
- Use consistent Home, Back, Area and Close behavior.
- Keep the current equipment identity visible in every detail view.
- Avoid opening multiple uncontrolled copies of the same popup.
2. Choose between a full picture, picture window and popup
| Display type | Suitable use | Design caution |
|---|---|---|
| Full picture | Area or process navigation | Preserve orientation and return path |
| Picture window | Embedded equipment detail | Manage instance context explicitly |
| Popup or dialog | Focused diagnostics or parameter entry | Control modality, position and duplicate instances |
| Faceplate | Standardized equipment operation | Define a stable interface and version |
3. Pass equipment context through an approved identifier
Instead of concatenating arbitrary operator input into tag names, map a known equipment identifier to an approved tag prefix.
Function ResolveMotorPrefix(ByVal equipmentId)
Select Case CStr(equipmentId)
Case "M101": ResolveMotorPrefix = "Plant1_M101"
Case "M102": ResolveMotorPrefix = "Plant1_M102"
Case "M103": ResolveMotorPrefix = "Plant1_M103"
Case Else: ResolveMotorPrefix = ""
End Select
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"An allowlist prevents malformed names and makes the supported instances visible during review.
4. Prepare a reusable equipment context
Sub SelectEquipment(ByVal equipmentId)
Dim prefix
prefix = ResolveMotorPrefix(equipmentId)
If prefix = "" Then
HMIRuntime.Trace "Unknown equipment: " & CStr(equipmentId) & vbCrLf
Exit Sub
End If
HMIRuntime.Tags("UI_SelectedEquipment").Write CStr(equipmentId)
HMIRuntime.Tags("UI_SelectedPrefix").Write prefix
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: UI_SelectedEquipment", "Easy Test 2 — InputBox + MsgBox", "1")
If TestValue = "" Then
MsgBox "Test cancelled.", vbInformation, "Tag Write Quick Test"
Else
MsgBox "SIMULATION ONLY" & vbCrLf & _
"Tag: UI_SelectedEquipment" & 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 IfInternal context tags are one possible pattern. Faceplate interfaces or picture-window properties may provide a cleaner supported mechanism in the installed release.
5. Bind the detail view consistently
The reusable view should read its approved context once, validate it and then bind captions, states and commands through a documented interface.
- Display the equipment identifier and description prominently.
- Use separate feedback and command tags.
- Show unavailable or bad-quality states explicitly.
- Reset stale context when the view closes.
6. Open the supported picture or popup
Use the documented WinCC function for the deployed edition. Keep the navigation request in one reusable function so version-specific calls are not duplicated throughout the project.
Sub OpenMotorDetail(ByVal equipmentId)
Call SelectEquipment(equipmentId)
'Call the supported picture-window or popup method here.
HMIRuntime.Trace "Motor detail requested: " & _
CStr(equipmentId) & vbCrLf
End Sub
Easy TestEasy Test 3 — InputBox + MsgBox
Self-contained procedure test; no PLC or SQL Server is required.
Sub ShowSQFValue(ByVal NameText, ByVal ValueText)
MsgBox NameText & " = " & ValueText, vbInformation, "Sub Quick Test"
End Sub
Dim TempAct
TempAct = InputBox("Enter Temp_Act", "Easy Test 3 — InputBox + MsgBox", "825.5")
Call ShowSQFValue("Temp_Act", TempAct)7. Design multi-instance faceplate commands safely
A reusable faceplate should submit a request for the selected instance, not write directly to an arbitrary constructed tag.
- Resolve the selected instance against the approved equipment map.
- Verify the current view still represents that instance.
- Apply WinCC authorization and operator confirmation where required.
- Write the request to the documented interface.
- Display the PLC acknowledgment or rejection reason.
8. Prevent stale context and navigation faults
| Failure mode | Prevention or diagnostic |
|---|---|
| Wrong motor details shown | Display and trace the resolved identifier and prefix |
| Old popup context remains | Initialize context on open and clear it on close |
| Duplicate popups | Check instance state before opening another |
| Object required error | Confirm active picture, window and exact object name |
| Navigation loop or dead end | Test every entry, close and return path |
9. Commission the reusable instance design
- Test every approved equipment identifier.
- Attempt an unknown identifier and confirm it is rejected.
- Change screens rapidly and verify context does not cross between instances.
- Test communication loss, user logout and PLC command rejection.
- Document the faceplate interface, tag map and version.
10. Example: one motor faceplate for three conveyors
An overview contains motors M101, M102 and M103. Selecting a motor resolves its approved prefix, updates the internal context and opens the same motor-detail view. The faceplate displays feedback, mode and fault information for that instance while command requests still pass through PLC validation.
Frequently asked questions
Should tag names be built directly from operator input?
No. Resolve a selected equipment identifier through an approved map or supported faceplate interface.
Why use one reusable faceplate?
It provides consistent behavior and reduces duplicated screens, but it also requires disciplined context validation and version control.
Can the popup method be copied between all WinCC editions?
No. Navigation and popup APIs vary. Verify the exact method in the installed product documentation.
SQF Running Project Lab · Blog 11
Carry SQF context into a detail popup
Dim SQFNo, Charge
SQFNo = HMIRuntime.Tags("SQF_No").Read
Charge = CStr(HMIRuntime.Tags("ChargeNo").Read)
HMIRuntime.Trace "Open SQF detail: " & SQFNo & _
" / Charge " & Charge & vbCrLf
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 SQF_No", "Easy Test 4 — InputBox + MsgBox", "TEST")
ResultText = ResultText & "SQF_No = " & TestValue & vbCrLf
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"