Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using strings for control names

Status
Not open for further replies.

marct

Programmer
Apr 6, 1999
32
0
0
US
I would like to be able to assemble a string based on different conditions and, when done, use that string as a control name. Can this be done in VB? For example, if I have three controls: lblMon, lblTue, & lblWed; I would like to create the name using strings such as:<br>
strDay = "Wed" (where under different conditions I would assign strDay = "Tue" or strDay = "Mon")<br>
strControlName = "lbl" + strDay<br>
and then use the strControlName string to assign the caption for, in this case, lblWed. Any ideas?
 
I do not think you can do that...<br>
you need to loop through your control collection and find the one that matches "strControlName ", (You can writ e a function to do that".<br>
Or what you can do is create a collection of conntrols and reference it with strControlName <br>
<br>
At startup:<br>
col.add lblMon,"lblMon"<br>
col.add lblTue,"lblTue"<br>
col.add lblWed,"lblWed"<br>
<br>
and then<br>
<br>
col(strControlName).caption = "New Caption"<br>
<br>
<br>
It should work<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top