Using an object - Defined by Text Combo

Kayot

Well-known member
Joined
Mar 6, 2007
Messages
49
Programming Experience
3-5
I've been trying to get this to work. I'm not even sure if it is possible.

I want to declare the object name then tell what happens to it.

Normal:

VB.NET:
Textbox.Text = ""

Advanced

VB.NET:
("TextBox_" & intVariable).Text = ""

Is there anyway to do it? I don't even know what to call it hence why I can't really search on it.
 
VB.NET:
Me.Controls("controlname").Text = "the text"
 
That worked, now heres a follow up question.

I used the above methode:

VB.NET:
Me.Controls("imgInvSlot_" & String).tag = ""

But now I want to add an image. However it fails and claim that image isn't part of the System.Windows.Forms.Control. So is there a way to do the following.

VB.NET:
Me.Control("imgInvSlot" & String).Image = My.Resources.etc

^-^ BTW, the above code worked wonderful.

P.S. I don't want to change the background image. Just image.
 
VB.NET:
Dim pb As PictureBox = Me.Controls("thepicturebox")
pb.Image = theimage
or
VB.NET:
DirectCast(Me.Controls("thepicturebox"), PictureBox).Image = theimage
 
Thanks JohnH, it worked ^-^.

My source code is working just fine now and I managed to remove this god awful loop that checked 600+ images hundreds of times. So I have one more questions; However, I'll have to make a new thread for it as it doesn't pertain to this topic.

Again thanks, ever time I ask a question I become a little less dumb.
 
Back
Top