FactoryTalk SE: How to toggle group visibility VBA?

instruward

Member
Join Date
Jul 2019
Location
Prairies
Posts
27
I'm trying to add text over a bunch of motors that indicate the mcc/section that is visible when a button is pushed (or preferably held) and invisible otherwise.

I'm unfamiliar with VBA, but I've found I can do Text1.Visible = False however I was trying to group all of that text together, but Group1.Visible = False does not work. Because there could be 20 motors on a page.
 
I'm trying to add text over a bunch of motors that indicate the mcc/section that is visible when a button is pushed (or preferably held) and invisible otherwise.

I'm unfamiliar with VBA, but I've found I can do Text1.Visible = False however I was trying to group all of that text together, but Group1.Visible = False does not work. Because there could be 20 motors on a page.


[Caveat: I am not a PLC guy, but I have done my fair share of VB]


I don't see your code, but it sounds like you have Text1, Text2, ..., Text20 labels.





if you can create them as an array of same name e.g. MotorText. The way it used to work is that there is a property of controls that says they are an array. If I remember correctly, it was an integer property named Index or summat like that; if it was empty then that control name was not an array; if it was a number then they would be an array. You may be able to change the Name property of Text1 to MotorText and its Index to 0, then the same for Text2 to MotorText/1, etc.





After that ou can refer to them as MotorText[0], MotorText[1], or even MotorText, where the variable "i" is a loop variable, and finally


Code:
  For i = 0 To 19
    MotorText[i].Visible = False   'or True
  Next
At this point I assume either you can take it from there, or I am completely clueless about what you are asking in which case I apologize for wasting your time.
 
Last edited:
Heh, now that I think about it, a simpler thing to do would be to move the group off-screen, e.g.


Group1.X = 2000


assumes the units of X are pixels and that the screen is less than 2000 pixels wide; use whatever value is <i>apropo</i> the units of X.


You could also leave it in place, turn off AutoSize (Group1.AutoSize = false) and set Group1.Width = 0 (or maybe 1?). Perhaps if the default size is (1,1), then toggling Group1.AutoSize will go from (1,1) when Group1.AutoSize is false, to something that shows all of your TextBox'es when Group1.AutoSize is true.


If nothing else, by posting wrong answers I will stimulate someone to post the right answer ...
 
Last edited:
Your first comment with the loop is exactly what I want to do, I just can't get the syntax right, but I'll try using what you wrote.

I never considered moving the group, that is interesting. Hopefully I get a chance tomorrow, I've been pulled away from this project for today. I'm just surprised I can't make a whole group visible/invisible. There is a groupvis property after all...
 
I've done something similar, but it was a long time ago.

I wanted to control visibility based on which client was accessing the display. My clients were identified as X2, X3, X4 and so on. What I ended up doing was putting in a VBA script to run when that display loaded, something along the lines of:
Code:
For Each Item In Elements
        If Item.Name Like "*X2Only" Then
            Item.Visible = True
        End If
    Next Item
Then, if I wanted something to only be visible on a certain client, say X2, I'd just name it Some_Object_Or_Other_X2Only and set the visible property to false. It will remain false unless the logic above finds it by name and makes it true.

The advantage of doing it this way is that I don't have to edit the VBA code each time I add a new object that needs to be included in this logic, I just have to name it correctly. From memory, this worked with both individual items and groups, but there may have been a limitation with nested groups. Again, it was a long time ago.
 
I've done something similar, but it was a long time ago. ,,,




This is a much better approach than my clumsy attempts to remember past glory.


Specifically, I am pretty sure you can loop over the controls that are children of the parent, something like


Code:
for tb in Group1.children
  tb.visible = false  'or true
next tb
 
[...]I'm just surprised I can't make a whole group visible/invisible. There is a groupvis property after all...


I have a vague recollection that VBA is lacking some of the features in VB.


Wait, try Group1.Visibility instead of Group1.Visible.


And as Google continues to spew stuff at me, see this
 
Last edited:
I'm trying to add text over a bunch of motors that indicate the mcc/section that is visible when a button is pushed (or preferably held) and invisible otherwise.

I'm unfamiliar with VBA, but I've found I can do Text1.Visible = False however I was trying to group all of that text together, but Group1.Visible = False does not work. Because there could be 20 motors on a page.


it was empty then that control name was not an array; if it was a number then they would be an array. You may be able to change the Name property of Text1 to MotorText and its Index to 0, then the same for Text2 to MotorText/1
 
Why use VBA?

Place all the text objects on the screen and tie the visibility property to a HMI tag. On the click event of the button set the HMI tag to 1
 
Why use VBA?

Place all the text objects on the screen and tie the visibility property to a HMI tag. On the click event of the button set the HMI tag to 1

I haven't figured out how to do that, so I started down the VBA rabbit hole.
I don't know where to make HMI tags, only tags on the plc which I want to avoid.
 
Why use VBA?

Place all the text objects on the screen and tie the visibility property to a HMI tag. On the click event of the button set the HMI tag to 1

This. Please keep it simple. Someone, more than likely, will have to work on this project at some point other than you.

HMI Tags are under 'HMI Tags' Make a 'Visible' tag, and get a button to toggle it on and off, right click your object and Animation > Visibilty, the rest is straight forward.
 
Your first comment with the loop is exactly what I want to do, I just can't get the syntax right, but I'll try using what you wrote.auto clicker
I never considered moving the group, that is interesting. Hopefully I get a chance tomorrow, I've been pulled away from this project for today. I'm just surprised I can't make a whole group visible/invisible. There is a groupvis property after all...


I'd just name it Some_Object_Or_Other_X2Only and set the visible property to false. It will remain false unless the logic above finds it by name and makes it true.
 

Similar Topics

I'm new to the forum and would like to say thanks in advance for any help you guys can give me. I'm relatively new to plcs but have a strong...
Replies
5
Views
2,608
Good Morning , I'm working on a FactoryTalk View ME project , and I'm using , out of the Symbol Factory , ( in the 3D Pushbutton group ) a...
Replies
7
Views
3,483
Hello, I was looking to store some values from our FactoryTalk Application using Datalog to a MariaDB. I see there is quite a bit of documentation...
Replies
1
Views
45
Hi Folks, who know why after start FactoryTalk activation manager V4.03, click "Get New Activations", it displays Is not I appreciate with any...
Replies
0
Views
48
I have a little bit of experience with Allen-Bradley. I have a Micrologix 1500 (RSLogix 500) and a PanelView Plus 7 (FactoryTalk View Studio ME)...
Replies
2
Views
82
Back
Top Bottom