VB for WinCC question
VB for WinCC question
(OP)
Hi there,
I'm relative new to VB, I got a small problem. I'm using WinCC with VBS, it's something like VBA in excel.
I've got one variable called Dummy, this var can contain three conditions namely 1,2 and 4. If it contains 1 then a tekst (Press 3)should be displayed in var Test and so on.
In fact it's a selection of 3 radio buttons, it depends on which button is clicked which tekst should be displayed.
I wrote the following code
Sub OnLButtonDown(ByVal Item, ByVal Flags, By Val x, By Val y)
Dim dummy, Test
Set Dummy = HMIRuntime.Tags(“Dummy”)
Set Test = HMIRuntime.Tags(“Test”)
If Dummy = 1 Then Test = (“Pers3”)
Else
If Dummy = 2 Then Test = (“Pers4”)
Else Test = (“Pers5”)
End IF
End IF
End Sub
What am I doing wrong ?
I'm relative new to VB, I got a small problem. I'm using WinCC with VBS, it's something like VBA in excel.
I've got one variable called Dummy, this var can contain three conditions namely 1,2 and 4. If it contains 1 then a tekst (Press 3)should be displayed in var Test and so on.
In fact it's a selection of 3 radio buttons, it depends on which button is clicked which tekst should be displayed.
I wrote the following code
Sub OnLButtonDown(ByVal Item, ByVal Flags, By Val x, By Val y)
Dim dummy, Test
Set Dummy = HMIRuntime.Tags(“Dummy”)
Set Test = HMIRuntime.Tags(“Test”)
If Dummy = 1 Then Test = (“Pers3”)
Else
If Dummy = 2 Then Test = (“Pers4”)
Else Test = (“Pers5”)
End IF
End IF
End Sub
What am I doing wrong ?





RE: VB for WinCC question
' WINCC:TAGNAME_SECTION_START
Const TagNameInAction = "Dummy"
Const TagNameInAction = "Test"
' WINCC:TAGNAME_SECTION_END
-Joe
RE: VB for WinCC question
Sub OnObjectChanged(ByVal Item)
Dim objTag
Dim selbutton
Dim buttonval
Set objTag = ScreenItems ("IOField4")
Set buttonval = ScreenItems ("OptionGroup1")
selbutton = buttonval.process
If selbutton = 1 Then
objTag.OutputValue = "Press 1"
Elseif selbutton = 2 Then
objTag.OutputValue = "Press 2"
Elseif selbutton = 4 Then
objTag.OutputValue = "Press 3"
Else
objTag.OutputValue = "Just here"
End If
End Sub
I am running WinCC v6.0 and have worked with it since v4. The VB scripting is a bit new to me but I'm playing with it.
RE: VB for WinCC question
Indeed I already solved the problem but thanks anyway. Perhaps I can help you in the future.
Rudi