Hello everybody, I have just joined this forum
I have a question to which I have not been able to find a good answer despite much googling.
The problem is to get an object reference, or other data type reference from a string. For example, suppose I have ten picturebox controls sequentially named PicBox1 to Picbox10 and I want to change their properties during runtime, but I want to do this using a string equal to their name, and I don't know at design time what that string value will be. Something like:
Dim BoxName As string
BoxName = InputBox("Please enter name of box")
'Then I want to do something like:
BoxName.Image = .......
The idea being that the user can type in the name of one of the pictureboxes, and that box's image will change to whatever I have specified in the ...... part of the above code.
I cannot find a way of doing this that doesn't cause an error. I get a "cannot convert string to picturebox" or something along those lines. What I want is the picture box whose name is the string.
I hope this makes sense, thanks in advance to anyone providing help.
I have a question to which I have not been able to find a good answer despite much googling.
The problem is to get an object reference, or other data type reference from a string. For example, suppose I have ten picturebox controls sequentially named PicBox1 to Picbox10 and I want to change their properties during runtime, but I want to do this using a string equal to their name, and I don't know at design time what that string value will be. Something like:
Dim BoxName As string
BoxName = InputBox("Please enter name of box")
'Then I want to do something like:
BoxName.Image = .......
The idea being that the user can type in the name of one of the pictureboxes, and that box's image will change to whatever I have specified in the ...... part of the above code.
I cannot find a way of doing this that doesn't cause an error. I get a "cannot convert string to picturebox" or something along those lines. What I want is the picture box whose name is the string.
I hope this makes sense, thanks in advance to anyone providing help.