read index value of a control

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

Guest

How do you read an index value of a control knowing the control's name?

Thanks


Pete
 
Alex,
I mean the index given to each control on a form, for example:

Me.Controls(5)

where the index 5 might be the index value of a text box "txtInput".

From the index, I can find the name of a control (Me.Controls(0).Name) but
how do I do it the other way round?

Many thanks
 
Try Me.Controls("controlName").index

Italian said:
Alex,
I mean the index given to each control on a form, for example:

Me.Controls(5)

where the index 5 might be the index value of a text box "txtInput".

From the index, I can find the name of a control (Me.Controls(0).Name) but
how do I do it the other way round?

Many thanks

:
 
Interesting! Why?

The plain search technique comes to mind (air code):

function getControlIndex(cName as string)as long
dim i as long
for i=0 to controls.count
if controls(i).name=cname then
getcontrolindex=i
exit for
endif
next
end function
 

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