繼續學習wincc下面VBA程式設計,這個練習實現變數線性標定。
在前面練習基礎上做,有REAL1至REAL10共10個變數,透過VBA指令碼對Real1至Real5設定線性標定。
寫下面的VBA指令碼:
Sub SetTagScaleParameter()
Dim hmigo As hmigo
Dim strTagName As String
Dim i As Integer
Set hmigo = New hmigo
For i = 1 To 5
strTagName = "Real" & CStr(i)
hmigo.ListTag TAG_NAMES, Tags, strTagName
If (UBound(Tags) - LBound(Tags) + 1) > 0 Then '如果變數存在
hmigo.GetTag strTagName
hmigo.TagScaleValid = True
hmigo.TagScaleParam1 = 0#
hmigo.TagScaleParam2 = 100#
hmigo.TagScaleParam3 = 0#
hmigo.TagScaleParam4 = 10#
hmigo.CommitTag
End If
Next
Set hmigo = Nothing
儲存,執行就自動的將5個變數做了線性標定。