Constructing control Names?!

kleky

Just gettin' by..
Local time
Today, 09:47
Joined
Apr 11, 2006
Messages
43
Hey guys, here's one for ya, hope you can help.

I have code that is very repetative and could easily be put into a loop, but, it is the control that is changing. As far as I know you cant concatenate strings and variables to form a control name...or can you (and reference the control)? :D

For example:

The control text1, text2, and text3

should ideally be...

For count = 1 To 3
"text" & count
Next

Cheers

Kleky
 
Sure you can

Me.Controls("Text" & Count)

or something very simular (to lazy to look at it now)

You can also do Controls(Count) this way your code loops thru all the controls, if you need to...

Greetz
 
Look into the Controls property, which is a collection, of the Form object.
Code:
dim i as integer

for i = 1 to 3
[COLOR="Green"]  'print the value of the control to the immediate pane[/COLOR]
  debug.print me.controls("text" & i)
next i
 
Wow, nice 1!!!!!!

There are so many little things like these I dont know...always learning!!

Muchos thankos!
 

Users who are viewing this thread

Back
Top Bottom