yronium Level: Moderator

 Registered: 14-04-2002 Posts: 907
|
Re: Referencing objects in loops
not sure if it helps, but...
when I have to refer to all the textboxes in a form, I use the following code:
Dim ctrl as Control
' clears all textboxes in Form1
For Each ctrl In Me.Controls
If TypeOf ctrl Is TextBox Then ctrl.Text = ""
Next ctrl
it seeks the Controls collection, and uses the TypeOf property. You can apply it to any type of control you have in your form.
You can also create an array of controls, by giving to each control the same name, and set each Index property to an index number.
____________________________
Real Programmer can count up to 1024 on his fingers
|