Learn WINCC with Real Code Examples
Updated Nov 27, 2025
Code Sample Descriptions
1
Hello World Message Box
MsgBox "Hello World from WinCC!"
Display a simple message box in WinCC.
2
Toggle Output Tag
If SmartTags("MotorOutput") = 0 Then
SmartTags("MotorOutput") = 1
Else
SmartTags("MotorOutput") = 0
End If
Toggle a digital output tag when the script is executed.
3
Increment Counter Tag
SmartTags("CounterTag") = SmartTags("CounterTag") + 1
Increment a counter tag by 1.
4
Alarm Trigger Based on Tag
If SmartTags("TempTag") > 80 Then
SmartTags("AlarmTag") = 1
Else
SmartTags("AlarmTag") = 0
End If
Set an alarm tag when temperature exceeds threshold.
5
Slider Control for Motor Speed
SmartTags("MotorSpeed") = SmartTags("SpeedSlider")
Set motor speed tag according to slider input tag.
6
Initialize Multiple Tags
Dim i
For i = 1 To 10
SmartTags("Output" & i) = 0
Next
Initialize an array of tags to 0 using a loop.
7
Read Multiple Tags and Calculate Total
SmartTags("TotalFlow") = SmartTags("FlowTag1") + SmartTags("FlowTag2")
Sum two flow tags and store in total tag.
8
Conditional Output Based on Multiple Tags
If SmartTags("StartButton") = 1 And SmartTags("SafetyOk") = 1 Then
SmartTags("MotorOutput") = 1
Else
SmartTags("MotorOutput") = 0
End If
Set output if two conditions are true.
9
Log Event with Timestamp
SmartTags("LogTag") = Now & " - Button Pressed"
Write a timestamped message to a string tag.
10
Reset All Outputs
Dim i
For i = 1 To 10
SmartTags("Output" & i) = 0
Next
Loop through outputs to reset them to 0.