Library code snippets
A quick way to toggle visibility
By Daniel Okely, published on 09 Oct 2001
If you want show something when its hidden, or hide it if its showing you may
do this:If Control1.Visible = True Then
Control1.Visible = False
ElseIf Control1.Visible = False Then
Control1.Visible = True
End If
However, a quicker way is to do:Control1.Visible = Not Control1.Visible
Also, if you have a menu like 'View Toolbar' you can use the resultant visibility
to set the checkmark on it. For Example
Private Sub mnuViewToolbar_Click()
tbToolbar.Visible = Not tbToolbar.Visible
mnuViewToolbar.Checked = tbToolbar.Visible
End Sub
By the way, if you make the item visible in the first place, make sure the menu
is checked by default.
Related articles
Related discussion
-
Run-time error '91'
by crazyidane (0 replies)
-
Problem handling Redirects with MSXML2.XMLHTTP
by brandoncampbell (2 replies)
-
vbinputbox pauses code while it waits on response. How can I reproduce that?
by brandoncampbell (1 replies)
-
Sending SMS in VB 6
by sirobnole (6 replies)
-
Comboxbox listindex in ActiveX Control
by brandoncampbell (1 replies)
My knowledge of VBA is very poor so I was wondering if someone could advise me how to disable menu items such as those that drop down from the FILE or TOOLS menus or even the whole menu.
What I would like to happen is that the menu item remains on the drop down list but is greyed out and disabled.
I hope that this makes sense.
I think it would be best to just introduce the not operator and then show its uses(like toggling visibility).
This thread is for discussions of A quick way to toggle visibility.