06-24-2003, 06:08 PM
Just wanna know how to do this :
I have several combo Box with name Combo1, Combo2.... Combo10
I have 2 variables (string) if concanated gives me the name of the Combo Box. What do i need to do so that i can reference to that object.
str1 = "combo"
str2 = "2"
???? (str1 & str2).text = "apple" ????
06-24-2003, 06:23 PM
I have no idea what you are trying to accomplish, but I'll bet it would be a lot easier if you used an array of combo boxes instead.
06-24-2003, 06:34 PM
Yeah... i've thought about the array... but now what about this instead :
i have only 1 combo box (cbBox)
and 1 string (str = "cbBox")
same problem... same question...
is there a way that i can use that string do what i wanted :
str.text = "apple"
I am just curious... someone must've asked this question... maybe not usefull... but quite challenging i think.
06-24-2003, 06:59 PM
Well, the short answer is no. A string variable has no text property therefore, str.text = "apple" will not work. You can declare an object variable like "MyCombo As ComboBox" but you can't declare an object variable as a specific control, such as "MyCombo As Combo1" that will not work. If you are only working with one combo box, I really don't see the point in trying to refer to it in code using a variable to hold it's name.
06-24-2003, 07:09 PM
Well... i guess i just found the answer...
Just loop through all the controls and find the one with same name, then you can use it..
ctl as control
For each ctl in me.controls
if ctl.name = str then ctl.text = "apple"