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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use a loop to reference an object? 3

Status
Not open for further replies.

solo7

Technical User
Mar 14, 2001
243
NO
Can I use a loop to reference an object?
I have 10 list boxes list0 - list9 and I want to perform actions on all of them. Instead of referencing them individually can I reference then from inside a loop? ie

For IntN=0 To 9
list & IntN.Visible=False
Next IntN

Obviously the above example does not work but it shows what I am trying to do.

solo7 [thumbsup2]
 
Thanks! this will save alot of typing ...

solo7
 
Good stuff Axoliien,

I'm sure a small oversight, but, In case not figured out already (by solo7), don't forget quotes.

Form.Controls("list" & IntN).Visible = False

...judging by the star, it may have been realised?

Either way, a helpful post!
 
I agree with dboulos, Good stuff Axoliien.
Gave both of you a Star!

dboulos for catching the typo!

solo7 if your not familiar with the ControlType Property, you may want to check that out. Another way to loop controls. Your not forced to name your fields like...
list1, list2, list3 you can give them meaningful names.

Easy way to view the ControlType Property...
type ControlType anywhere in the VBE window, highlight it, then press F1

I think you may find this a little more resourceful when dealing with other controls.


AccessGuruCarl
Programmers helping programmers
you can't find a better site.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top