A quick way to toggle visibility

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.

You might also like...

Comments

Daniel Okely -Daniel Okely Inaugural Developerfusion.com Prize Winner

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Every language has an optimization operator. In C++ that operator is ‘//’”