|
-
Dec 13th, 2010, 11:03 AM
#1
Thread Starter
Addicted Member
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
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?
-
Dec 13th, 2010, 11:14 AM
#2
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"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|