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
Warsteiner99Asked:
Who is Participating?
 
danlevansConnect With a Mentor Commented:
Private Sub Command24_Click()
    Command27.Visible = False 'invisable
    Command27.Visible = True 'visable
End Sub
0
 
VbmasterCommented:
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.
0
All Courses

From novice to tech pro — start learning today.