Hi,
I'm working with Factory Talk Studio and VBA coding. So far, I have two questions. If someone could help me I would be really glad.
First, I have a global object which has a Touch animation and three parameters: Window, IndexNo and Text.
I've created a bunch of tags (HMI, not in PLC) named Index000 to Index100, all of them in Nav folder (Nav\Index001 for instance).
Suppose my parameters are #1 MyWindow, #2 100 and #3 MyButtonText.
My object runs "&Display #1; &Set Nav\Index#2 = 1".
My code needs to read the #2 parameter (IndexNo) so that it can write 0 or 1 in a specific Nav\Index###.
What I've done until now: I can read and write to HMI tags using
What I really wanted:
The code above won't work. How can I read #2 parameter? Is that possible?
Now my second obstacle: although time consuming, I could create a window with, say, 10 objects, ranging from My_Object001 to My_Object010. Then I would have 10 VB subs on a window and could change "Code 1"'s IndexNumber of each one to its right number, i.e. 001..010. Still, "Display" command (set in the Global Object) won't work when I use VB code (it works fine when I don't). Why?
I might be missing (correction: i'm sure i'm missing) something, since I'm new to FTView and VBA. So please, correct me if I made any mistake or if anything isn't clear.
Thank you very much for your attention.
I'm working with Factory Talk Studio and VBA coding. So far, I have two questions. If someone could help me I would be really glad.
First, I have a global object which has a Touch animation and three parameters: Window, IndexNo and Text.
I've created a bunch of tags (HMI, not in PLC) named Index000 to Index100, all of them in Nav folder (Nav\Index001 for instance).
Suppose my parameters are #1 MyWindow, #2 100 and #3 MyButtonText.
My object runs "&Display #1; &Set Nav\Index#2 = 1".
My code needs to read the #2 parameter (IndexNo) so that it can write 0 or 1 in a specific Nav\Index###.
What I've done until now: I can read and write to HMI tags using
Code:
'Code 1:
Private Sub MyGObject_Click()
IndexNumber = 100
{Code here so that it will waits 10 seconds}
If My_Group.Item("Nav\Index" & IndexNumber).Value = 1 Then
My_Group.Item("Nav\Index" & IndexNumber).Value = 0
End if
End Sub
What I really wanted:
Code:
'Code 2:
Private Sub MyGObject_Click()
[B]IndexNumber = Me.Parameters(2)[/B] 'Reads #2 parameter and stores in IndexNumber variable
{Code here so that it will waits 10 seconds}
If My_Group.Item("Nav\Index" & IndexNumber).Value = 1 Then
My_Group.Item("Nav\Index" & IndexNumber).Value = 0
End if
End Sub
The code above won't work. How can I read #2 parameter? Is that possible?
Now my second obstacle: although time consuming, I could create a window with, say, 10 objects, ranging from My_Object001 to My_Object010. Then I would have 10 VB subs on a window and could change "Code 1"'s IndexNumber of each one to its right number, i.e. 001..010. Still, "Display" command (set in the Global Object) won't work when I use VB code (it works fine when I don't). Why?
I might be missing (correction: i'm sure i'm missing) something, since I'm new to FTView and VBA. So please, correct me if I made any mistake or if anything isn't clear.
Thank you very much for your attention.