Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing values of multiple objects

Status
Not open for further replies.

sjn78

Programmer
Feb 22, 2003
92
AU
IS there a simple way to do this.

text1.visible = true
text2.visible = true
text3.visible = true

I have a lot of these types of controls on a form and needed to know whether you can do it all in 1 line of code instead of the above method.

I would like to stay away from arrays.

Thanks

Steve
 
The first method that comes to mind would be to create a control array and then loop through it. But you want to stay away from control arrays.

The other method would be to use the forms control collection.

Dim MyControl As Control

For Each MyControl In Me.Controls()
If TypeOf MyControl Is Label Then
MyControl.Visible = False
ElseIf TypeOf MyControl Is TextBox Then
MyControl.Visible = False
ElseIf TypeOf MyControl Is CommandButton Then
MyControl.Visible = False
End If
Next MyControl
Thanks and Good Luck!

zemp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top