Link to home
Start Free TrialLog in
Avatar of Warsteiner99
Warsteiner99

asked on

Command Button Visibility

How do you make a command button via a button on the program, called Command24, make bottons called command 27-37, go from invisible to visible mode, and visa versa
ASKER CERTIFIED SOLUTION
Avatar of danlevans
danlevans

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Vbmaster
Vbmaster

You really should use array controls instead of using Command1, Command2, Command3 etc

Here's how to do it if you do NOT use a array control...

  Dim Control As Control

  For Each Control In Controls
    If (Control.Name Like "Command2[789]") Then
      Control.Visible = Not Control.Visible
    End If
  Next

If you used a array control you would use the code...

  Dim a As Long
  For a = 27 To 29
    Command(a).Visible = Not Command(a).Visible
  Next

If you want to convert your command buttons to a array control you can set the first buttons name to 'Command' or something, then set the second button to the same name, the third to same name etc. VB will ask you if you want to create a array control when you set the name of the second button.. you do want to do that.


Hope this helps.