control indexes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,

How do I find the control indexes on a form, etc. I would like to write a
little sub to initialize the controls on a form, and rather than referencing
each I'd like to for-next and use index numbers. Nothing in Properties that I
can see.

Thank you,

Ra
 
Simplest way to loop through the controls on a form would be:
Dim ctl As Control
For each ctl in Me.Controls
Debug.Print ctl.Name
Next

If you really want to use index numbers:
Dim i As Integer
For i = 0 to Me.Controls.Count -1
Debug.Print Me.Controls(i).Name
Next
 
Thank you so much Allen.

Allen Browne said:
Simplest way to loop through the controls on a form would be:
Dim ctl As Control
For each ctl in Me.Controls
Debug.Print ctl.Name
Next

If you really want to use index numbers:
Dim i As Integer
For i = 0 to Me.Controls.Count -1
Debug.Print Me.Controls(i).Name
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top