[RESOLVED] Option Button --Simple question
I have an option button array. How do I return the number of the option that is selected. I'm thinking something like:
HTML Code:
whatever = Option1.number
Please forgive my ignorance... I'm teaching myself how to program and have had no formal training.
Thanks.
Sincerely,
J
Re: Option Button --Simple question
You need to loop through the array to check which has been selected, or you can store the index when it is being selected.
VB Code:
'Loop through the items.
Dim iSelectedIndex As Integer
For iSelectedIndex = 0 To Option1.UBound
If Option1(iSelectedIndex).Value = True Then
'Found the one that is selected, exit the loop
Exit For
End If
Next
MsgBox "Selected item has index " & uSelectedIndex
VB Code:
'Storing the item when it is being selected
Private iSelectedItem As Integer
Private Sub Option1_Click(Index As Integer)
iSelectedItem = Index
End Sub
Re: Option Button --Simple question
Thanks a Brazilian! (That's a big number!)
Re: Option Button --Simple question
Quote:
Originally Posted by JW2000
Thanks a Brazilian! (That's a big number!)
Oh...? It's just not a south-american fotball (soccer) player then? :)
I hope you notice the little typo I made in my first code example...
VB Code:
MsgBox "Selected item has index " & uSelectedIndex
'Should of course be:
MsgBox "Selected item has index " & [b]i[/b]SelectedIndex