is there an Eval() in Excel VBA
I'm not sure I entirely understand what you're trying to do, but this code
might be a start. It allows you to set an object reference to a control based
on the name.
Note that I dimensioned the controls with the generic term "Control" instead
of specifying "TextBox" or whatever they might be. Once you've got the
reference to the control, you can still access all the properties and methods
for that control even if they don't show up on the auto list members view.
Dim I As Integer
Dim C As Control, objMyControl As Control
I = 2 ' You can supply the value of I any way you want, from a parameter, etc.
For Each C In Me.Controls
If C.Name = "txtControl" & I Then
Set objMyControl = C
Exit For
End If
Next
' Do stuff with your control objMyControl
Set objMyControl = Nothing
--
Hmm...they have the Internet on COMPUTERS now!
"clara" wrote:
Hi all,
I am going to handle a group of controls which are in
"txtControl1","txtControl2",
"txtControl3",... format. So, It is likely to use a loop in which the
"txtControl" part is concacted with the number part like "txtControl"&i, so I
like to use a Eval function to converse the string "txtControl"& i into
control. How can I do it?
CLara
--
thank you so much for your help
|