Variable Label Name

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
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
 
Back
Top