Object reference from string

  • Thread starter Thread starter Rob Henderson
  • Start date Start date
R

Rob Henderson

I have many objects on a form that I would like to
update/modify with some VB code. I would like to iterate
through the object names with a loop. Is there a function
like the following?

dim _obj as object
dim i as integer
for i = 1 to 4
set _obj = SomeFunction("formobject" & CStr(i))
_obj.Value = i
next i

....rather than this...

formobject1.value = 1
formobject2.value = 2
formobject3.value = 3
formobject4.value = 4

Thanks
 
If your talking about text boxes, yes.
Just name them appropriately:
txt1, txt2, txt3 etc

You can then loop

For i = 1 To 3
Me("txt" & i) = i
Next
 
Back
Top