[code]Sub Button1_OnClick()
Dim sTagPath
sTagPath = "DB1.RUN" ' 这里的DB1.RUN表示变量RUN所在的DB块及名称
If ReadValue(sTagPath) = 0 Then
WriteValue sTagPath, 1 ' 将变量RUN置为1
Else
WriteValue sTagPath, 0 ' 将变量RUN置为0
End If
End Sub
Function ReadValue(sTagPath)
' 读取指定变量的值
Dim oTag
Set oTag = HMIRuntime.Tags(sTagPath)
ReadValue = oTag.Read
End Function
Sub WriteValue(sTagPath, nValue)
' 设置指定变量的值
Dim oTag
Set oTag = HMIRuntime.Tags(sTagPath)
oTag.Write nValue
End Sub[/code]