What is wrong in VBS

ggchavhan

Member
Join Date
Nov 2006
Location
pune
Posts
135
Hi

I have a simple button in WinCC 6.2, I wanted to toggle its status from false to true and vice versa at every click. For this I tried no of ways but no joy

1.
Sub OnLButtonDown(ByVal Item, ByVal Flags, ByVal x, ByVal y)

Dim gg
Set gg = HMIRuntime.Tags("gg")
gg = Not gg
HMIRuntime.Tags("gg").Write(gg)
End Sub

2.
Sub OnLButtonDown(ByVal Item, ByVal Flags, ByVal x, ByVal y)

Dim gg
gg = HMIRuntime.Tags("gg").read
gg = Not gg
HMIRuntime.Tags("gg").Write(gg)
End Sub

Can anybody tell me what is wrong in above code
 
Last edited:
Is "gg" defined as a boolean or an integer?
You may want to try "Set gg as boolean" if it a boolean type.
The other way if it is an integer is to use as in the following snippet. I don't know WinCC and you will have to convert it to the correct format.

If gg = 1 then
gg = 0
else gg = 1
End if
 
Hi
I am also not so old working with VBS in WINCC (especially in VB). I've made several tests with your program and I found the proper sintax:

Sub OnLButt.........
Dim gg
gg = HMIRuntime.Tags("gg").read
If gg=1 Then
gg=0
Else
gg=1
End If
HMIRuntime.Tags("gg").Write gg
End Sub

Supposing "gg" binnary tag.
I discovered myself taht Not, True, Flase dont work under WINCC (like so many others). You must also not to use Set for values.
http://www.eng-tips.com/viewthread.cfm?qid=70365&page=5

Good Luck,
Teckhno
 
Thanks Mark

actually I wanted to check NOT operation with expression
so when I tried to declare
Dim gg As Boolean .. while check it is showing some error.

Other option you mentioned it's done.
 
From the other thread:
Please, Gonzela;
Please realize that I have already given you the basic tool to answer all your questions; the fact that you choose not to use it can be unnerving...
http://support.automation.siemens.co...ew/en/17356933

You really should read the getting started manual as previously suggested and in particular I would recommend section 2 on starting your first project; This is a step by step guide.

Nick
 

Similar Topics

I am latching and unlatching "result_Data_latch" bit within same rung. Will This copy/move instruction execute correctly??
Replies
4
Views
211
We have a quad monitor setup with FT SE and we are utilizing a header screen at the top of every display. when we open a new page we abort the...
Replies
0
Views
117
Hi all, I am having an issue with FT View Studio ME when I try to open the propoerties of any object, the size of it is very big and doesn't let...
Replies
0
Views
113
ewrong aka the censored brand of remote access this thing is kicking my butt and im not sure if i am just irritated enough that i am missing...
Replies
5
Views
662
In Easy Builder Pro: Unexpected results... I've got a toggle switch set to trigger a macro to write a specified integer or a 0 depending on the...
Replies
7
Views
2,345
Back
Top Bottom