WinCC V12 VB Help

JDCROCKETT724

Member
Join Date
Jun 2010
Location
Michigan
Posts
249
I am trying to write a simple VB code to increment a tag to page through some data collection. What I have compiles without errors, but does not seem to work when I push the button that executes the code. Here is what I have

IncreaseTag"OP2_DATA_COLLECTION_PAGE",1

If SmartTags("OP2_DATA_COLLECTION_PAGE")=2 Then
SetBit("OP2_DATA_COLLECTION_HIDE_PAGEUP")
End If

ResetBit"OP2_DATA_COLLECTION_HIDE_PAGEDOWN"

Any ideas on what I am doing wrong here? All the tags I am trying to manipulate are present in my "HMI Tags" file as internal tags.
 
It actually appears the script is not running at all when I press my button to activate it. I added the function ActivatePreviousScreen and this did not work either.
 
Just a guess. Lots of assumptions about what you are doing - I probably got it wrong. But hopefully give you a bit of food for thought.

Keep in mind there are time delays between the SCADA and the PLC tag read/write. So I would get the current value of the tag once in the SCADA, then use that value in the SCADA. Same problem on the set/reset of the bit: remember about the time delays.

So how about:

MyTag = SmartTags("OP2_DATA_COLLECTION_PAGE")

If (MyTag + 1) = 2 Then
SetBit("OP2_DATA_COLLECTION_HIDE_PAGEUP")
ResetBit("OP2_DATA_COLLECTION_HIDE_PAGEDOWN")
else
ResetBit("OP2_DATA_COLLECTION_HIDE_PAGEUP")
SetBit("OP2_DATA_COLLECTION_HIDE_PAGEDOWN")
End If

IncreaseTag "OP2_DATA_COLLECTION_PAGE",1
 
Last edited:
I actually commented my logic out as you can see and it still didn't Activate the previous screen. This makes me believe that the script isn't running at all even though it is call up under my "Click" event.

Sub Page_Up()
'Tip:
' 1. Use the <CTRL+SPACE> or <CTRL+I> keystroke to open a list of all objects and functions
' 2. Write the code using the HMIRuntime object.
' Example: HmiRuntime.Screens("Screen_1").
' 3. Use the <CTRL+J> keystroke to create an object reference.
'Write the code as of this position:

'IncreaseTag "OP2_DATA_COLLECTION_PAGE",1

ActivatePreviousScreen

'If SmartTags("OP2_DATA_COLLECTION_PAGE")=2 Then
' SetBit("OP2_DATA_COLLECTION_HIDE_PAGEUP")
'End If

'ResetBit"OP2_DATA_COLLECTION_HIDE_PAGEDOWN"

End Sub
 
Awhile back, we had a button ever so slightly overlapping another button - one or both would not work. Try checking that first ...
 
Using the below script I copied from a siemens manual I was able to get it to work. So it must be my code that is wrong. How do I write a script to change a value in the an HMI tag?

Dim objCircle
Set objCircle = HmiRuntime.Screens(1).ScreenItems("Circle1")
objCircle.BackColor = RGB(255,0,0)
 

Similar Topics

hello all, I have a project in Wincc V15 and I need to copy some screens from V15 to V12 TIA. How do I it. I cant copy paste as there are...
Replies
2
Views
1,921
I want to prepare a PC for a client that has TIA Portal WinCC V12 professional RT. I dont have the installation DVD that came with Siemens as it...
Replies
1
Views
2,981
Dear all, I used WinCC professional V12 for the first time and I am experiecing very slow responce of the system. The programm is made so that...
Replies
0
Views
2,533
I am trying to write a script that will change an internal tag in the HMI. I am having no luck on getting this to work. Does anyone have any...
Replies
4
Views
3,213
I want a Cognex application I have installed on my TP1200 to start in the back ground when the runtime starts. Does anyone know how to do this...
Replies
1
Views
1,866
Back
Top Bottom