
Cycle through all controls on a form
Quote:
>Is it possible to cycle through all controls on a form? I'd like to do sth
>like:
>For Each Ctrl In [Controls on current form]
> If {Ctrl is Label} Then 'or I can check it by: Ctrl.Tag = sth
> Ctrl.BackColor = PrefinedColor
> End If
>Next
>TIA
>--------------------------------------
>emsi
>[no idea 4 sig]
Try it like so....
For Each Ctrl In Me.Controls
If TypeOf Ctrl Is Label Then
Ctrl.BackColor = PrefinedColor
End If
Next
If this code is running somewhere other than the current form, you
will need to change the "Me" reference to a reference to the desired
form.
HTH,
Bryan
____________________________________________________________
New Vision Software "When the going gets weird,"
Bryan Stafford "the weird turn pro."
Microsoft MVP-Visual Basic Fear and Loathing in LasVegas