Convert string to textbox

James

Well-known member
Joined
Oct 3, 2002
Messages
78
How do I convert a string to a textbox object?

Ex.

dim strTest as string

strTest="textbox" & 1

I want to convert strTest to a textbox object

Thanks,

James
 
Are you saying you need to take a string and reference an existing control by name or to create a control using that name?

If you want to create a control, thats easy. If you want to reference an existing control by name, it can be done but Im not sure off-hand. Why would you need to know the control name at runtime (not design time)? Maybe theres an easier way to do what youre needing...

-Nerseus
 
Im trying to reference an existing control by name. The reason Im doing this at runtime is because I am trying to add javascript blur() event to alot of textboxes. When the blur() event executes a javascript function will do some calculations. I have a lot of textboxes and I want to streamline my code. Below is what Im trying to do with the textboxes.


I have textboxes with the ids jan3, feb3, mar3...jan13,feb13, mar13

For s = 3 To 13
MonthAttr(jan & s)
MonthAttr(feb & s)
MonthAttr(mar & s)
MonthAttr(apr & s)
.
.
.
Next s


Private Sub MonthAttr(ByVal mon As Object)
mon.Attributes.Add("onblur", "calculate()")
End Sub

Thanks,

James
 
If anyone wants to know I found the solution. This converts a string to a object control.

month1 = FindControl("jan" & s)

James
 
Yes, is right forum....

So for my sake...

month1 = FindControl("jan" & s)

will make a var/object named Month1 that is equivalent to Jan13 for instance???
 
Back
Top