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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Concatinate Control Name 1

Status
Not open for further replies.

aw23

Programmer
Nov 26, 2003
544
IL
I have 5 lbls, lbl1, lbl2, lbl3, etc.
I have a string with 5 letters. I want to put one letter in each label. Is it possible to concatinate the name so that I don't have to go through each label? Here is my code which does not work:

Code:
While i < Len(strName)
    i = i + 1
    num = Mid(strName, i, 1)
    lbl = "lbl" & i
    Call FillID(lbl, num)
Wend
End Sub
Private Sub FillID(lbl As Label, idNum)
lbl.Caption = idNum
End Sub

I tried it a few different ways but all produced errors.
Any suggestions?
Thanks!
 
If the Labels and the code are in a UserForm:
Private Sub FillID(lbl As String, idNum)
Me.Controls(lbl).Caption = idNum
End Sub

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Which application is this?

I suppose both Word/Excel Userforms and Access forms would accept something like this:

[tt]Call FillID(me.controls(lbl), num)[/tt]

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top