Hi
Could anyone please tell me how to store a certain index value in an integer?
I am trying to retrieve the index of the selected radio button from an array of radio buttons.
Thanks
Printable View
Hi
Could anyone please tell me how to store a certain index value in an integer?
I am trying to retrieve the index of the selected radio button from an array of radio buttons.
Thanks
Code:Dim i As Integer
For i = Option1.LBound To Option1.UBound
If Option1(i).Value = True Then
MsgBox "You selected Option " & i
Exit For
End If
Next i
Or you could set up a simple little Property to store the Index that is selected.
Code:Option Explicit
Private mintIndex As Integer
Private Sub Command1_Click()
MsgBox "The radio button with Index " & RadioButtonSelected & " is selected."
End Sub
Public Property Get RadioButtonSelected() As Integer
RadioButtonSelected = mintIndex
End Property
Public Property Let RadioButtonSelected(ByVal intIndex As Integer)
mintIndex = intIndex
End Property
Private Sub Option1_Click(Index As Integer)
RadioButtonSelected = Index
End Sub