Softwell WinCC VBScript — Handwritten M-Step Manual
Day 01 - PLC to PLC Communication Using VBScript
Practical Outcome: Read WinCC source tags, validate values, write destination PLC tags and prepare a reusable transfer script.
A. Step-by-Step Procedure
'Basic read/write pattern using SmartTags
Dim level
level = SmartTags("PLC1_TankLevel")
SmartTags("PLC2_TankLevel_SP") = level
Easy TestEasy Test 1 — InputBox + MsgBox
Beginner-safe declaration test with visible output.
Option Explicit
Dim TestValue
TestValue = InputBox("Enter a value for this declaration example", "Easy Test 1 — InputBox + MsgBox", "825.5")
MsgBox "Variable successfully declared and assigned." & vbCrLf & _
"Value = " & TestValue, vbInformation, "Declaration Quick Test"'Button action: CopyPLC1ToPLC2
Dim tags(3)
tags(0) = "TankLevel" : tags(1) = "Pressure"
tags(2) = "Temperature" : tags(3) = "MotorCmd"
Dim i
For i = 0 To 3
SmartTags("PLC2_" & tags(i)) = SmartTags("PLC1_" & tags(i))
Next
SmartTags("SYS_LastTransferStatus") = "TRANSFER OK"
SmartTags("SYS_LastTransferTime") = Now()
Easy TestEasy Test 2 — InputBox + MsgBox
Shows the exact timestamp formatting used later in tblEvent.TM.
Dim LabelText, TM
LabelText = InputBox("Enter a label for this timestamp", "Easy Test 2 — InputBox + MsgBox", "SQF Event")
TM = Right("0" & Hour(Now), 2) & ":" & _
Right("0" & Minute(Now), 2) & ":" & _
Right("0" & Second(Now), 2)
MsgBox LabelText & vbCrLf & _
"Date/Time = " & Now & vbCrLf & _
"TM = " & TM, vbInformation, "Date/Time Quick Test"Dim srcLevel, srcPressure
srcLevel = SmartTags("PLC1_TankLevel")
srcPressure = SmartTags("PLC1_Pressure")
If IsNumeric(srcLevel) And srcLevel >= 0 And srcLevel <= 100 Then
If IsNumeric(srcPressure) And srcPressure >= 0 And srcPressure <= 10 Then
SmartTags("PLC2_TankLevel") = srcLevel
SmartTags("PLC2_Pressure") = srcPressure
SmartTags("SYS_LastTransferStatus") = "OK"
Else
SmartTags("SYS_LastTransferStatus") = "ERR: PRESSURE OUT OF RANGE"
End If
Else
SmartTags("SYS_LastTransferStatus") = "ERR: INVALID LEVEL"
End If
SmartTags("SYS_LastTransferTime") = Now()
Easy TestEasy Test 3 — InputBox + MsgBox
Shows the exact timestamp formatting used later in tblEvent.TM.
Dim LabelText, TM
LabelText = InputBox("Enter a label for this timestamp", "Easy Test 3 — InputBox + MsgBox", "SQF Event")
TM = Right("0" & Hour(Now), 2) & ":" & _
Right("0" & Minute(Now), 2) & ":" & _
Right("0" & Second(Now), 2)
MsgBox LabelText & vbCrLf & _
"Date/Time = " & Now & vbCrLf & _
"TM = " & TM, vbInformation, "Date/Time Quick Test"B. Verification Checklist
- The project/configuration completes without an unresolved compile or device error.
- Online, simulation or runtime values respond in the expected sequence for Day 01 - PLC to PLC Communication Using VBScript.
- Critical addresses, parameters, units and initial states are checked against the lab sheet.
- The saved project can be reopened and the result reproduced without hidden manual correction.
C. If the Result Is Wrong
| Symptom | Probable cause | Diagnostic check | Corrective action |
|---|---|---|---|
| Compile or configuration error | Unresolved device, tag, type, address or parameter | Open the first diagnostic entry and trace it to the configured object | Correct the source item, compile again and save a new evidence record |
| No online/runtime response | Wrong connection, command source, permissions or scan state | Monitor live values from input through logic to output | Restore the verified connection/state and repeat one controlled test |
| Unstable or unexpected value | Scaling, initial state, timing or version mismatch | Compare raw and engineering values and review the installed version | Correct scaling/state, reset the lab safely and retest |
D. Student Evidence Record
Record software version, controller/device firmware, driver and license status.
Save the project/archive name, modified block/object and parameter list.
Capture a verified screenshot, trend, alarm, tag table or measured value.
Write the pass condition, fault tested, correction made and final observation.
| Practical | Day 01 - PLC to PLC Communication Using VBScript | Pass condition | Observed result matches the stated objective and can be repeated. |
|---|---|---|---|
| Evidence filename | ________________ | Trainer / self-check | ________________ |
Daily Practice / Viva
Explain code line-by-line, show Runtime working screen, SQL query result and one troubleshooting point for Day 01.
Expected Result and Runtime Behavior
Day 01 - PLC to PLC Communication Using VBScript completes with the stated configuration or code behavior, no unresolved diagnostic, a repeatable verification result and a saved evidence record.
Skills & Tools You Will Learn
Important automation skills are arranged for job-level, project-level and Industry 4.0 learning.
Softwell WinCC VBScript — Handwritten M-Step Manual
Day 02 - Internal Tag Logging to SQL Server
Practical Outcome: Create Softwell_DB table and log WinCC internal tags into SQL Server using ADODB VBScript.
A. Step-by-Step Procedure
-- Run in SQL Server Management Studio
USE Softwell_DB;
CREATE TABLE InternalTagLog (
Id INT IDENTITY(1,1) PRIMARY KEY,
LogTime DATETIME NOT NULL DEFAULT GETDATE(),
BatchNo NVARCHAR(50),
SetPoint FLOAT,
ActualValue FLOAT,
OperatorName NVARCHAR(100),
ShiftName NVARCHAR(20)
);
Easy TestEasy Test 4 — InputBox + MsgBox
Change the InputBox values to force different IF/ELSE outcomes.
Dim TestValue, ResultText
TestValue = CDbl(InputBox("Enter a test value", "Easy Test 4 — InputBox + MsgBox", "75"))
If TestValue >= 80 Then
ResultText = "HIGH"
ElseIf TestValue >= 50 Then
ResultText = "NORMAL"
Else
ResultText = "LOW"
End If
MsgBox "Input = " & TestValue & vbCrLf & "Result = " & ResultText, vbInformation, "Condition Quick Test"Dim cn, sql, connStr
Set cn = CreateObject("ADODB.Connection")
connStr = "Provider=SQLOLEDB;" & _
"Data Source=.\SQLEXPRESS;" & _
"Initial Catalog=Softwell_DB;" & _
"Integrated Security=SSPI;"
cn.Open connStr
sql = "INSERT INTO InternalTagLog" & _
"(LogTime, BatchNo, SetPoint, ActualValue, OperatorName, ShiftName) VALUES (" & _
"GETDATE(), '" & SmartTags("INT_BatchNo") & "', " & _
SmartTags("INT_SetPoint") & ", " & _
SmartTags("INT_ActualValue") & ", '" & _
SmartTags("INT_OperatorName") & "', '" & _
SmartTags("INT_ShiftName") & "')"
cn.Execute sql
cn.Close
Set cn = Nothing
Easy TestEasy Test 5 — InputBox + MsgBox
Safe preview for a database-changing example; it does not execute INSERT/UPDATE/DELETE.
Dim ChargeNo, TempAct, SQLPreview
ChargeNo = InputBox("Enter Charge Number", "Easy Test 5 — InputBox + MsgBox", "CHG-001")
TempAct = InputBox("Enter actual temperature", "Easy Test 5 — InputBox + MsgBox", "825.5")
SQLPreview = "Target: SQF_DB.dbo.tblEvent" & vbCrLf & _
"ChargeNo = " & ChargeNo & vbCrLf & _
"Temp_Act = " & TempAct
MsgBox SQLPreview & vbCrLf & vbCrLf & _
"SAFE TEST: review these values before running the database command above.", _
vbInformation, "ADO / SQL Quick Test"Dim cn, sql, connStr, errMsg
On Error Resume Next
Set cn = CreateObject("ADODB.Connection")
connStr = "Provider=SQLOLEDB;Data Source=.\SQLEXPRESS;" & _
"Initial Catalog=Softwell_DB;Integrated Security=SSPI;"
cn.Open connStr
If Err.Number <> 0 Then
SmartTags("SYS_DBStatus") = "CONN ERR: " & Err.Description
Err.Clear
Else
sql = "INSERT INTO InternalTagLog(LogTime, BatchNo, SetPoint, ActualValue) VALUES (" & _
"GETDATE(), '" & SmartTags("INT_BatchNo") & "', " & _
SmartTags("INT_SetPoint") & ", " & SmartTags("INT_ActualValue") & ")"
cn.Execute sql
If Err.Number <> 0 Then
SmartTags("SYS_DBStatus") = "SQL ERR: " & Err.Description
Err.Clear
Else
SmartTags("SYS_DBStatus") = "OK " & Now()
End If
cn.Close
End If
Set cn = Nothing
On Error GoTo 0
Easy TestEasy Test 6 — InputBox + MsgBox
Safe preview for a database-changing example; it does not execute INSERT/UPDATE/DELETE.
Dim ChargeNo, TempAct, SQLPreview
ChargeNo = InputBox("Enter Charge Number", "Easy Test 6 — InputBox + MsgBox", "CHG-001")
TempAct = InputBox("Enter actual temperature", "Easy Test 6 — InputBox + MsgBox", "825.5")
SQLPreview = "Target: SQF_DB.dbo.tblEvent" & vbCrLf & _
"ChargeNo = " & ChargeNo & vbCrLf & _
"Temp_Act = " & TempAct
MsgBox SQLPreview & vbCrLf & vbCrLf & _
"SAFE TEST: review these values before running the database command above.", _
vbInformation, "ADO / SQL Quick Test"B. Verification Checklist
- The project/configuration completes without an unresolved compile or device error.
- Online, simulation or runtime values respond in the expected sequence for Day 02 - Internal Tag Logging to SQL Server.
- Critical addresses, parameters, units and initial states are checked against the lab sheet.
- The saved project can be reopened and the result reproduced without hidden manual correction.
C. If the Result Is Wrong
| Symptom | Probable cause | Diagnostic check | Corrective action |
|---|---|---|---|
| Compile or configuration error | Unresolved device, tag, type, address or parameter | Open the first diagnostic entry and trace it to the configured object | Correct the source item, compile again and save a new evidence record |
| No online/runtime response | Wrong connection, command source, permissions or scan state | Monitor live values from input through logic to output | Restore the verified connection/state and repeat one controlled test |
| Unstable or unexpected value | Scaling, initial state, timing or version mismatch | Compare raw and engineering values and review the installed version | Correct scaling/state, reset the lab safely and retest |
D. Student Evidence Record
Record software version, controller/device firmware, driver and license status.
Save the project/archive name, modified block/object and parameter list.
Capture a verified screenshot, trend, alarm, tag table or measured value.
Write the pass condition, fault tested, correction made and final observation.
| Practical | Day 02 - Internal Tag Logging to SQL Server | Pass condition | Observed result matches the stated objective and can be repeated. |
|---|---|---|---|
| Evidence filename | ________________ | Trainer / self-check | ________________ |
Daily Practice / Viva
Explain code line-by-line, show Runtime working screen, SQL query result and one troubleshooting point for Day 02.
Expected Result and Runtime Behavior
Day 02 - Internal Tag Logging to SQL Server completes with the stated configuration or code behavior, no unresolved diagnostic, a repeatable verification result and a saved evidence record.
Softwell WinCC VBScript — Handwritten M-Step Manual
Day 03 - External PLC Tag Logging to SQL Server
Practical Outcome: Log live PLC/OPC/S7 process values from WinCC external tags into SQL with quality and batch information.
A. Step-by-Step Procedure
-- SQL table for external (PLC) process data
USE Softwell_DB;
CREATE TABLE ProcessTagLog (
Id INT IDENTITY(1,1) PRIMARY KEY,
LogTime DATETIME NOT NULL DEFAULT GETDATE(),
TagName NVARCHAR(100) NOT NULL,
TagValue FLOAT,
Unit NVARCHAR(20),
QualityCode INT,
BatchNo NVARCHAR(50)
);
CREATE INDEX IX_ProcessLog_Time ON ProcessTagLog(LogTime DESC);
CREATE INDEX IX_ProcessLog_Tag ON ProcessTagLog(TagName, LogTime DESC);
Easy TestEasy Test 7 — InputBox + MsgBox
Change the InputBox values to force different IF/ELSE outcomes.
Dim TestValue, ResultText
TestValue = CDbl(InputBox("Enter a test value", "Easy Test 7 — InputBox + MsgBox", "75"))
If TestValue >= 80 Then
ResultText = "HIGH"
ElseIf TestValue >= 50 Then
ResultText = "NORMAL"
Else
ResultText = "LOW"
End If
MsgBox "Input = " & TestValue & vbCrLf & "Result = " & ResultText, vbInformation, "Condition Quick Test"'Cyclic action: LogPLCTagsToSQL (cycle: 5 s)
Dim cn, connStr, cmd, rs
Dim tagNames(3), tagUnits(3), i
Dim val, batchNo
tagNames(0) = "EXT_Reactor_Temp" : tagUnits(0) = "degC"
tagNames(1) = "EXT_Reactor_Pressure" : tagUnits(1) = "bar"
tagNames(2) = "EXT_FlowRate" : tagUnits(2) = "L/min"
tagNames(3) = "EXT_AgitatorRPM" : tagUnits(3) = "rpm"
batchNo = SmartTags("INT_BatchNo")
On Error Resume Next
Set cn = CreateObject("ADODB.Connection")
connStr = "Provider=SQLOLEDB;Data Source=.\SQLEXPRESS;" & _
"Initial Catalog=Softwell_DB;Integrated Security=SSPI;"
cn.Open connStr
If Err.Number = 0 Then
For i = 0 To 3
val = SmartTags(tagNames(i))
If IsNumeric(val) Then
cn.Execute "INSERT INTO ProcessTagLog(LogTime,TagName,TagValue,Unit,BatchNo)" & _
" VALUES(GETDATE(),'" & tagNames(i) & "'," & val & _
",'" & tagUnits(i) & "','" & batchNo & "')"
End If
Next
SmartTags("SYS_DBStatus") = "PLC LOG OK " & Now()
cn.Close
Else
SmartTags("SYS_DBStatus") = "CONN ERR: " & Err.Description
Err.Clear
End If
Set cn = Nothing
On Error GoTo 0
Easy TestEasy Test 8 — InputBox + MsgBox
Safe preview for a database-changing example; it does not execute INSERT/UPDATE/DELETE.
Dim ChargeNo, TempAct, SQLPreview
ChargeNo = InputBox("Enter Charge Number", "Easy Test 8 — InputBox + MsgBox", "CHG-001")
TempAct = InputBox("Enter actual temperature", "Easy Test 8 — InputBox + MsgBox", "825.5")
SQLPreview = "Target: SQF_DB.dbo.tblEvent" & vbCrLf & _
"ChargeNo = " & ChargeNo & vbCrLf & _
"Temp_Act = " & TempAct
MsgBox SQLPreview & vbCrLf & vbCrLf & _
"SAFE TEST: review these values before running the database command above.", _
vbInformation, "ADO / SQL Quick Test"'Extended cyclic logger with quality check
Dim cn, i, val, qual, tagName, batchNo
Dim tagNames(3)
tagNames(0) = "EXT_Reactor_Temp"
tagNames(1) = "EXT_Reactor_Pressure"
tagNames(2) = "EXT_FlowRate"
tagNames(3) = "EXT_AgitatorRPM"
batchNo = SmartTags("INT_BatchNo")
On Error Resume Next
Set cn = CreateObject("ADODB.Connection")
cn.Open "Provider=SQLOLEDB;Data Source=.\SQLEXPRESS;" & _
"Initial Catalog=Softwell_DB;Integrated Security=SSPI;"
If Err.Number = 0 Then
For i = 0 To 3
tagName = tagNames(i)
val = SmartTags(tagName)
qual = SmartTags(tagName).QualityCode 'WinCC quality 192 = Good
If IsNumeric(val) And qual = 192 Then
cn.Execute "INSERT INTO ProcessTagLog(LogTime,TagName,TagValue,QualityCode,BatchNo)" & _
" VALUES(GETDATE(),'" & tagName & "'," & val & "," & qual & ",'" & batchNo & "')"
End If
Next
cn.Close
End If
Set cn = Nothing
On Error GoTo 0
Easy TestEasy Test 9 — InputBox + MsgBox
Safe preview for a database-changing example; it does not execute INSERT/UPDATE/DELETE.
Dim ChargeNo, TempAct, SQLPreview
ChargeNo = InputBox("Enter Charge Number", "Easy Test 9 — InputBox + MsgBox", "CHG-001")
TempAct = InputBox("Enter actual temperature", "Easy Test 9 — InputBox + MsgBox", "825.5")
SQLPreview = "Target: SQF_DB.dbo.tblEvent" & vbCrLf & _
"ChargeNo = " & ChargeNo & vbCrLf & _
"Temp_Act = " & TempAct
MsgBox SQLPreview & vbCrLf & vbCrLf & _
"SAFE TEST: review these values before running the database command above.", _
vbInformation, "ADO / SQL Quick Test"B. Verification Checklist
- The project/configuration completes without an unresolved compile or device error.
- Online, simulation or runtime values respond in the expected sequence for Day 03 - External PLC Tag Logging to SQL Server.
- Critical addresses, parameters, units and initial states are checked against the lab sheet.
- The saved project can be reopened and the result reproduced without hidden manual correction.
C. If the Result Is Wrong
| Symptom | Probable cause | Diagnostic check | Corrective action |
|---|---|---|---|
| Compile or configuration error | Unresolved device, tag, type, address or parameter | Open the first diagnostic entry and trace it to the configured object | Correct the source item, compile again and save a new evidence record |
| No online/runtime response | Wrong connection, command source, permissions or scan state | Monitor live values from input through logic to output | Restore the verified connection/state and repeat one controlled test |
| Unstable or unexpected value | Scaling, initial state, timing or version mismatch | Compare raw and engineering values and review the installed version | Correct scaling/state, reset the lab safely and retest |
D. Student Evidence Record
Record software version, controller/device firmware, driver and license status.
Save the project/archive name, modified block/object and parameter list.
Capture a verified screenshot, trend, alarm, tag table or measured value.
Write the pass condition, fault tested, correction made and final observation.
| Practical | Day 03 - External PLC Tag Logging to SQL Server | Pass condition | Observed result matches the stated objective and can be repeated. |
|---|---|---|---|
| Evidence filename | ________________ | Trainer / self-check | ________________ |
Daily Practice / Viva
Explain code line-by-line, show Runtime working screen, SQL query result and one troubleshooting point for Day 03.
Expected Result and Runtime Behavior
Day 03 - External PLC Tag Logging to SQL Server completes with the stated configuration or code behavior, no unresolved diagnostic, a repeatable verification result and a saved evidence record.
Why Choose Softwell Automation
Learn automation with practical examples, industrial troubleshooting approach and complete IT/OT learning path.
Softwell WinCC VBScript — Handwritten M-Step Manual
Day 04 - Conditional Logic IF / ELSE Writing to SQL
Practical Outcome: Use If, ElseIf, Select Case, threshold logic, shift detection and de-bounce before writing events to SQL.
A. Step-by-Step Procedure
'De-bounce pattern: only write when state changes
Dim curState, prevState
curState = SmartTags("EXT_Reactor_Temp")
prevState = SmartTags("INT_PrevReactorTemp")
If Abs(curState - prevState) > 0.5 Then
'Value changed by more than 0.5 degrees - log it
SmartTags("INT_PrevReactorTemp") = curState
'...INSERT to SQL...
End If
Easy TestEasy Test 10 — InputBox + MsgBox
Change the InputBox values to force different IF/ELSE outcomes.
Dim TestValue, ResultText
TestValue = CDbl(InputBox("Enter a test value", "Easy Test 10 — InputBox + MsgBox", "75"))
If TestValue >= 80 Then
ResultText = "HIGH"
ElseIf TestValue >= 50 Then
ResultText = "NORMAL"
Else
ResultText = "LOW"
End If
MsgBox "Input = " & TestValue & vbCrLf & "Result = " & ResultText, vbInformation, "Condition Quick Test"-- EventLog table for condition-based logging
USE Softwell_DB;
CREATE TABLE EventLog (
Id INT IDENTITY(1,1) PRIMARY KEY,
EventTime DATETIME NOT NULL DEFAULT GETDATE(),
EventType NVARCHAR(50) NOT NULL, -- 'THRESHOLD','SHIFT','FAULT'
TagName NVARCHAR(100),
TagValue FLOAT,
Description NVARCHAR(255),
ShiftName NVARCHAR(20),
OperatorName NVARCHAR(100)
);
Easy TestEasy Test 11 — InputBox + MsgBox
Change the InputBox values to force different IF/ELSE outcomes.
Dim TestValue, ResultText
TestValue = CDbl(InputBox("Enter a test value", "Easy Test 11 — InputBox + MsgBox", "75"))
If TestValue >= 80 Then
ResultText = "HIGH"
ElseIf TestValue >= 50 Then
ResultText = "NORMAL"
Else
ResultText = "LOW"
End If
MsgBox "Input = " & TestValue & vbCrLf & "Result = " & ResultText, vbInformation, "Condition Quick Test"'Cyclic action: ThresholdLogger (cycle: 2 s)
Dim temp, pressure, flow, desc, evType
Dim cn, prevFaultFlag
temp = SmartTags("EXT_Reactor_Temp")
pressure = SmartTags("EXT_Reactor_Pressure")
flow = SmartTags("EXT_FlowRate")
prevFaultFlag = SmartTags("INT_FaultLogged")
desc = ""
evType = ""
If temp > 95 Then
evType = "THRESHOLD"
desc = "CRITICAL: Reactor Temp = " & temp & " degC (limit 95)"
ElseIf temp > 85 Then
evType = "WARNING"
desc = "HIGH WARN: Reactor Temp = " & temp & " degC"
End If
If pressure > 8 Then
evType = "THRESHOLD"
desc = desc & " | CRIT PRESSURE: " & pressure & " bar"
End If
If flow < 5 And flow >= 0 Then
evType = "THRESHOLD"
desc = desc & " | LOW FLOW: " & flow & " L/min"
End If
'Only log if new fault detected and not already logged
If evType <> "" And prevFaultFlag = 0 Then
On Error Resume Next
Set cn = CreateObject("ADODB.Connection")
cn.Open "Provider=SQLOLEDB;Data Source=.\SQLEXPRESS;" & _
"Initial Catalog=Softwell_DB;Integrated Security=SSPI;"
If Err.Number = 0 Then
cn.Execute "INSERT INTO EventLog(EventTime,EventType,TagName,TagValue,Description)" & _
" VALUES(GETDATE(),'" & evType & "','REACTOR'," & temp & ",'" & desc & "')"
cn.Close
SmartTags("INT_FaultLogged") = 1
End If
Set cn = Nothing
On Error GoTo 0
ElseIf evType = "" Then
SmartTags("INT_FaultLogged") = 0 'Reset when conditions return to normal
End If
Easy TestEasy Test 12 — InputBox + MsgBox
Safe preview for a database-changing example; it does not execute INSERT/UPDATE/DELETE.
Dim ChargeNo, TempAct, SQLPreview
ChargeNo = InputBox("Enter Charge Number", "Easy Test 12 — InputBox + MsgBox", "CHG-001")
TempAct = InputBox("Enter actual temperature", "Easy Test 12 — InputBox + MsgBox", "825.5")
SQLPreview = "Target: SQF_DB.dbo.tblEvent" & vbCrLf & _
"ChargeNo = " & ChargeNo & vbCrLf & _
"Temp_Act = " & TempAct
MsgBox SQLPreview & vbCrLf & vbCrLf & _
"SAFE TEST: review these values before running the database command above.", _
vbInformation, "ADO / SQL Quick Test"B. Verification Checklist
- The project/configuration completes without an unresolved compile or device error.
- Online, simulation or runtime values respond in the expected sequence for Day 04 - Conditional Logic IF / ELSE Writing to SQL.
- Critical addresses, parameters, units and initial states are checked against the lab sheet.
- The saved project can be reopened and the result reproduced without hidden manual correction.
C. If the Result Is Wrong
| Symptom | Probable cause | Diagnostic check | Corrective action |
|---|---|---|---|
| Compile or configuration error | Unresolved device, tag, type, address or parameter | Open the first diagnostic entry and trace it to the configured object | Correct the source item, compile again and save a new evidence record |
| No online/runtime response | Wrong connection, command source, permissions or scan state | Monitor live values from input through logic to output | Restore the verified connection/state and repeat one controlled test |
| Unstable or unexpected value | Scaling, initial state, timing or version mismatch | Compare raw and engineering values and review the installed version | Correct scaling/state, reset the lab safely and retest |
D. Student Evidence Record
Record software version, controller/device firmware, driver and license status.
Save the project/archive name, modified block/object and parameter list.
Capture a verified screenshot, trend, alarm, tag table or measured value.
Write the pass condition, fault tested, correction made and final observation.
| Practical | Day 04 - Conditional Logic IF / ELSE Writing to SQL | Pass condition | Observed result matches the stated objective and can be repeated. |
|---|---|---|---|
| Evidence filename | ________________ | Trainer / self-check | ________________ |
Daily Practice / Viva
Explain code line-by-line, show Runtime working screen, SQL query result and one troubleshooting point for Day 04.
Expected Result and Runtime Behavior
Day 04 - Conditional Logic IF / ELSE Writing to SQL completes with the stated configuration or code behavior, no unresolved diagnostic, a repeatable verification result and a saved evidence record.
Choose the Correct WinCC Practical Manual
Each manual has a separate subject focus and SEO pathway. This page is dedicated only to WinCC VBScript and its SQL-based scripting applications.
Softwell WinCC VBScript — Handwritten M-Step Manual
Day 05 - Alarms, Recipes and Trends via VBScript
Practical Outcome: Build final VBScript integration: alarm logging, SQL recipe load/save and SQL-based custom trend data.
A. Step-by-Step Procedure
-- AlarmLog table for custom alarm history
USE Softwell_DB;
CREATE TABLE AlarmLog (
Id INT IDENTITY(1,1) PRIMARY KEY,
AlarmTime DATETIME NOT NULL DEFAULT GETDATE(),
AlarmNo INT,
AlarmClass NVARCHAR(50),
AlarmText NVARCHAR(255),
AlarmState NVARCHAR(20), -- CAME_IN / WENT_OUT / ACKED
TagName NVARCHAR(100),
TagValue FLOAT,
OperatorName NVARCHAR(100),
ShiftName NVARCHAR(20)
);
Easy TestEasy Test 13 — InputBox + MsgBox
Change the InputBox values to force different IF/ELSE outcomes.
Dim TestValue, ResultText
TestValue = CDbl(InputBox("Enter a test value", "Easy Test 13 — InputBox + MsgBox", "75"))
If TestValue >= 80 Then
ResultText = "HIGH"
ElseIf TestValue >= 50 Then
ResultText = "NORMAL"
Else
ResultText = "LOW"
End If
MsgBox "Input = " & TestValue & vbCrLf & "Result = " & ResultText, vbInformation, "Condition Quick Test"'Tag change action on alarm bit tag @OM_ALM_1
'Triggered when alarm state bit changes
Dim cn, alarmState, alarmText, stateStr
alarmState = SmartTags("@OM_ALM_1")
alarmText = "High Temperature Reactor 01"
Select Case alarmState
Case 1: stateStr = "CAME_IN"
Case 2: stateStr = "WENT_OUT"
Case 4: stateStr = "ACKED"
Case Else: stateStr = "UNKNOWN"
End Select
On Error Resume Next
Set cn = CreateObject("ADODB.Connection")
cn.Open "Provider=SQLOLEDB;Data Source=.\SQLEXPRESS;" & _
"Initial Catalog=Softwell_DB;Integrated Security=SSPI;"
If Err.Number = 0 Then
cn.Execute "INSERT INTO AlarmLog(AlarmTime,AlarmNo,AlarmClass,AlarmText,AlarmState," & _
"TagName,TagValue,OperatorName,ShiftName)" & _
" VALUES(GETDATE(),1,'HIGH_TEMP','" & alarmText & "','" & stateStr & _
"','EXT_Reactor_Temp'," & SmartTags("EXT_Reactor_Temp") & _
",'" & SmartTags("INT_OperatorName") & _
"','" & SmartTags("SYS_CurrentShift") & "')"
cn.Close
End If
Set cn = Nothing
On Error GoTo 0
Easy TestEasy Test 14 — InputBox + MsgBox
Safe preview for a database-changing example; it does not execute INSERT/UPDATE/DELETE.
Dim ChargeNo, TempAct, SQLPreview
ChargeNo = InputBox("Enter Charge Number", "Easy Test 14 — InputBox + MsgBox", "CHG-001")
TempAct = InputBox("Enter actual temperature", "Easy Test 14 — InputBox + MsgBox", "825.5")
SQLPreview = "Target: SQF_DB.dbo.tblEvent" & vbCrLf & _
"ChargeNo = " & ChargeNo & vbCrLf & _
"Temp_Act = " & TempAct
MsgBox SQLPreview & vbCrLf & vbCrLf & _
"SAFE TEST: review these values before running the database command above.", _
vbInformation, "ADO / SQL Quick Test"-- Recipe parameters table
USE Softwell_DB;
CREATE TABLE RecipeData (
Id INT IDENTITY(1,1) PRIMARY KEY,
RecipeName NVARCHAR(100) NOT NULL,
Param_TempSP FLOAT,
Param_PressureSP FLOAT,
Param_FlowSP FLOAT,
Param_MixTime INT,
Param_AgitatorRPM INT,
CreatedBy NVARCHAR(100),
CreatedAt DATETIME DEFAULT GETDATE()
);
Easy TestEasy Test 15 — InputBox + MsgBox
Change the InputBox values to force different IF/ELSE outcomes.
Dim TestValue, ResultText
TestValue = CDbl(InputBox("Enter a test value", "Easy Test 15 — InputBox + MsgBox", "75"))
If TestValue >= 80 Then
ResultText = "HIGH"
ElseIf TestValue >= 50 Then
ResultText = "NORMAL"
Else
ResultText = "LOW"
End If
MsgBox "Input = " & TestValue & vbCrLf & "Result = " & ResultText, vbInformation, "Condition Quick Test"'Button action: LoadRecipe
'Reads selected recipe from SQL and writes SP tags
Dim cn, rs, sql, recipeName
recipeName = SmartTags("INT_SelectedRecipe") 'e.g. "BATCH_A"
On Error Resume Next
Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
cn.Open "Provider=SQLOLEDB;Data Source=.\SQLEXPRESS;" & _
"Initial Catalog=Softwell_DB;Integrated Security=SSPI;"
sql = "SELECT TOP 1 * FROM RecipeData WHERE RecipeName='" & recipeName & "'"
rs.Open sql, cn
If Not rs.EOF Then
SmartTags("INT_TempSP") = rs("Param_TempSP")
SmartTags("INT_PressureSP") = rs("Param_PressureSP")
SmartTags("INT_FlowSP") = rs("Param_FlowSP")
SmartTags("INT_MixTime") = rs("Param_MixTime")
SmartTags("INT_AgitatorRPM") = rs("Param_AgitatorRPM")
SmartTags("SYS_DBStatus") = "RECIPE LOADED: " & recipeName
Else
SmartTags("SYS_DBStatus") = "ERR: Recipe not found - " & recipeName
End If
rs.Close : cn.Close
Set rs = Nothing : Set cn = Nothing
On Error GoTo 0
Easy TestEasy Test 16 — InputBox + MsgBox
Live connection test only; it does not modify dbo.tblEvent.
On Error Resume Next
Dim ServerName, Conn
ServerName = InputBox("Enter SQL Server\Instance", "Easy Test 16 — InputBox + MsgBox", "SOFTWELL\WINCC")
Set Conn = CreateObject("ADODB.Connection")
Conn.Open "Provider=MSOLEDBSQL;Server=" & ServerName & ";Database=SQF_DB;Trusted_Connection=Yes;"
If Err.Number <> 0 Then
MsgBox "CONNECTION FAILED" & vbCrLf & Err.Description, vbCritical, "SQL Quick Test"
Err.Clear
Else
MsgBox "CONNECTION OK" & vbCrLf & "Database = SQF_DB", vbInformation, "SQL Quick Test"
End If
If Not Conn Is Nothing Then
If Conn.State = 1 Then Conn.Close
End If
Set Conn = Nothing
On Error GoTo 0B. Verification Checklist
- The project/configuration completes without an unresolved compile or device error.
- Online, simulation or runtime values respond in the expected sequence for Day 05 - Alarms, Recipes and Trends via VBScript.
- Critical addresses, parameters, units and initial states are checked against the lab sheet.
- The saved project can be reopened and the result reproduced without hidden manual correction.
C. If the Result Is Wrong
| Symptom | Probable cause | Diagnostic check | Corrective action |
|---|---|---|---|
| Compile or configuration error | Unresolved device, tag, type, address or parameter | Open the first diagnostic entry and trace it to the configured object | Correct the source item, compile again and save a new evidence record |
| No online/runtime response | Wrong connection, command source, permissions or scan state | Monitor live values from input through logic to output | Restore the verified connection/state and repeat one controlled test |
| Unstable or unexpected value | Scaling, initial state, timing or version mismatch | Compare raw and engineering values and review the installed version | Correct scaling/state, reset the lab safely and retest |
D. Student Evidence Record
Record software version, controller/device firmware, driver and license status.
Save the project/archive name, modified block/object and parameter list.
Capture a verified screenshot, trend, alarm, tag table or measured value.
Write the pass condition, fault tested, correction made and final observation.
| Practical | Day 05 - Alarms, Recipes and Trends via VBScript | Pass condition | Observed result matches the stated objective and can be repeated. |
|---|---|---|---|
| Evidence filename | ________________ | Trainer / self-check | ________________ |
Daily Practice / Viva
Explain code line-by-line, show Runtime working screen, SQL query result and one troubleshooting point for Day 05.
Expected Result and Runtime Behavior
Day 05 - Alarms, Recipes and Trends via VBScript completes with the stated configuration or code behavior, no unresolved diagnostic, a repeatable verification result and a saved evidence record.
Frequently Asked Questions About WinCC VBScript 05 Days Handwritten Code Manual
Who can join this training?
Students, freshers, working engineers, maintenance teams and corporate plant engineers can join based on their requirement.
Is practical training included?
Yes. The training is focused on PLC, SCADA, HMI, VFD, communication, troubleshooting and project based practice.
Can I request online or corporate training?
Yes. Softwell Automation provides classroom, online, corporate and in-plant training options.
Before You Start: Prerequisites, Tested Version, Safety and Evidence
This manual is a practical training workbook, not a substitute for the installed product manual or the site's approved engineering procedure. Record the exact software, firmware, license and hardware before following a step because menus and supported functions can vary by release.
Tested-version planning scope: Confirm WinCC V7.5 or the installed Classic/Professional release that supports VBScript; WinCC Unified uses JavaScript instead. Enter the exact lab-tested software, firmware and hardware in the record below before course delivery; never assume cross-version compatibility.
Software build, firmware, device catalog, driver, communication interface and license status.
Use an isolated training system. Follow electrical, mechanical, process and cybersecurity controls before energizing or downloading.
Keep the source project, parameter/code export, screenshot/trend, fault test, correction and final pass result.
Last reviewed by Softwell Automation Technical Training Team on 17 July 2026.
| Field | Learner record | Verification |
|---|---|---|
| Software / firmware | ________________ | Matches the training device and official compatibility information |
| Project / backup | ________________ | Saved before and after the practical |
| Pass evidence | ________________ | Runtime value, trend, alarm, diagnostic or report attached |
| Fault tested | ________________ | Symptom, cause, check and corrective action documented |
Practice, Viva and Extension Challenge
Change one approved input or parameter, predict the result, execute the test and explain any difference.
Explain the data flow, safety boundary, first diagnostic check and recovery method without opening the answer.
Add one useful function while preserving the original pass criteria, alarm behavior and rollback path.
Combine at least three practicals, submit a versioned project and evidence pack, and demonstrate repeatable recovery.
Content status: Substantively reviewed and expanded 17 July 2026. Verify release-specific details against the linked official documentation.
Five-Day Practical Navigation
Complete each day in sequence and retain the code/parameter file, runtime proof, diagnosis record and signed conclusion.
