I don't know if what I would like to accomplish is possible in VB, but here it is. Lets say my program creates a set of labels at run time. These labels will be named Label_n (n being an index value to uniquely identify the object). Later in my program, I would like to set the text of one of these labels, say Label_4. Is there a way to add a variable as part of another variables reference? I invision this similarly to concatenation like "Label_" + index Thank you in advance for any help or other suggestions.

Recommended Answers

All 2 Replies

You can reference a control dynamically by name by

Dim lbl As Label = Me.Controls("label_" & "2")
lbl.Text = "splunge"

Thanks, that's exactly what I need.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.