M
Mike Bazoo
I am a novice vb.net programmer and hope someone can help me.
For a questionnaire, I have several (100+) radio buttons whose names
follow this standard:
radAlways1, radAlways2, 3.. 10
radUsually1, radUsually2, 3...10
radSometimes1, radSometimes2, 3...10
etc
My ultimate goal is to loop through each one and do an action on the
ones that are 'Checked'.
In order to try to reduce the amount of code, I created Strings inside
each loop which generate radio buttons names. Something like this:
For intCount = 0 To 10
strAlways = "radAlways" & intCount + 1
strUsually = "radUsually" & intCount + 1
strSometimes = "radSometimes" & intCount + 1
strSeldom = "radSeldom" & intCount + 1
strNever = "radNever" & intCount + 1
...'Rest of code here
Next intCount
This part actually works fine which the strings having the right radio
buttons names in each loop iteration.
Now, my question is: how can I use this correctly generated string as
the RadioButton object in order to be able to call RadioButton's
methods ('Checked' in particular)?
For intCount = 0 To 2
strAlways = "radAlways" & intCount + 1
strUsually = "radUsually" & intCount + 1
strSometimes = "radSometimes" & intCount + 1
'HERE IS WHERE I WANT TO USE THE STRING VALUE
'AS THE RADIOBUTTON IN ORDER TO CALL THE 'CHECKED' METHOD.
'I DO NOT WANT TO HARDCODE THE ACTUAL RADIOBUTTON OBJECT
NAME.
If radAlways1.Checked = True Then
'do something
ElseIf radUsually1.Checked = True Then
'do something
ElseIf radSometimes1.Checked = True Then
'do something
End If
Next intCount
I am also open for other ideas on how to accomplish this.
Thanks.
For a questionnaire, I have several (100+) radio buttons whose names
follow this standard:
radAlways1, radAlways2, 3.. 10
radUsually1, radUsually2, 3...10
radSometimes1, radSometimes2, 3...10
etc
My ultimate goal is to loop through each one and do an action on the
ones that are 'Checked'.
In order to try to reduce the amount of code, I created Strings inside
each loop which generate radio buttons names. Something like this:
For intCount = 0 To 10
strAlways = "radAlways" & intCount + 1
strUsually = "radUsually" & intCount + 1
strSometimes = "radSometimes" & intCount + 1
strSeldom = "radSeldom" & intCount + 1
strNever = "radNever" & intCount + 1
...'Rest of code here
Next intCount
This part actually works fine which the strings having the right radio
buttons names in each loop iteration.
Now, my question is: how can I use this correctly generated string as
the RadioButton object in order to be able to call RadioButton's
methods ('Checked' in particular)?
For intCount = 0 To 2
strAlways = "radAlways" & intCount + 1
strUsually = "radUsually" & intCount + 1
strSometimes = "radSometimes" & intCount + 1
'HERE IS WHERE I WANT TO USE THE STRING VALUE
'AS THE RADIOBUTTON IN ORDER TO CALL THE 'CHECKED' METHOD.
'I DO NOT WANT TO HARDCODE THE ACTUAL RADIOBUTTON OBJECT
NAME.
If radAlways1.Checked = True Then
'do something
ElseIf radUsually1.Checked = True Then
'do something
ElseIf radSometimes1.Checked = True Then
'do something
End If
Next intCount
I am also open for other ideas on how to accomplish this.
Thanks.