Select object from radiobutton
Hey,
I have two labels on my form
Label1
Label2
In the form load I generate a radiobutton for each label, with the text property being the name of the label.
So two radiobuttons are made
The first one will have text: Label1
I have
Quote:
dim objStore as object
Example:
I select the first radiobutton (text: Label1)
Then Label1 should be stored in objStore as object.
So then I can do
objStore.text = "test"
Any help?
Re: Select object from radiobutton
Sounds like you want to access a control by its variable name when all you have is a string that is equal to the variable name. The only way to do that is to use the forms controls collection to access a control by its name, and stick that into your variable. Note you shouldn't use type "object" to store a control, because it won't have the properties of a control you will want to set (like the .text property). You can use the actual type 'label' or the base type 'control' if you plan to store a control reference other than a label in objStore.
Code:
Dim objStore As Control
objStore = Me.Controls(radiobutton1.text)
objStore.Text = "test"