Variable Label Name

S

Sven Daems

Hy group

I've a great number of labels, all called lbl1,lbl2,lbl3,... When the form
opens, there set to visible = No. When running a code, I've in a loop a
counter who has the value 1, 2, 3, ... When the counter has the value 1, the
label lbl1 has to be visible, when the counter has the value 2, label lbl1
and lbl2 has to be visible, and so on... I know I've seen a code on the msdn
website where you can adres to a label with a variable labelname. I've tried
things
like lbl & X.Visible = true or lbl(X).Visible = true (X is the counter) but
it doesn't work.

Does anybody has a solution?
 
D

Dirk Goldgar

Sven Daems said:
Hy group

I've a great number of labels, all called lbl1,lbl2,lbl3,... When the
form opens, there set to visible = No. When running a code, I've in
a loop a counter who has the value 1, 2, 3, ... When the counter has
the value 1, the label lbl1 has to be visible, when the counter has
the value 2, label lbl1 and lbl2 has to be visible, and so on... I
know I've seen a code on the msdn website where you can adres to a
label with a variable labelname. I've tried things
like lbl & X.Visible = true or lbl(X).Visible = true (X is the
counter) but it doesn't work.

Does anybody has a solution?

Me.Controls("lbl" & X).Visible = True
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top