[RESOLVED]How to get the caption of a radio button with a function
Hello guys, I hope you can give me a hand.
I want to have a function that I can pass a frame to (a frame that contains a group of radio buttons), and return the caption of the button selected. Basically I have two problems, I dont know how to pass the form to the function. second, I dont know how to access the properties of the frame within the function. This is the code. It does not work at all, I post it so you guys get an idea of what I want.
Thanks
Hello guys, I hope you can give me a hand.
I want to have a function that I can pass a frame to (a frame that contains a group of radio buttons), and return the caption of the button selected. Basically I have two problems, I dont know how to pass the form to the function. second, I dont know how to access the properties of the frame within the function. This is the code. It does not work at all, I post it so you guys get an idea of what I want.
Thanks
Code:
Private Sub Toggle8_Click()
Dim str As String
str = getSelectedOptionInFrame(Me.Frame0)
MsgBox "the caption of the buton is" & str
End Sub
Public Function getSelectedOptionInFrame(fraFrame As Frame) As String
Dim bytNumOptions As Byte 'The number of options in the frame
Dim i As Byte 'Counter
bytNumOptions = fraFrame.Controls.count 'HERE I WANT TO COUNT ONLY OPTION BUTTONS
For i = 1 To bytNumOptions 'I WANT TO LOOP ONLY OPTION BUTTONS
If fraFrame = i Then ' the selected option button
'I WANT TO RETURN THE CAPTION OF THE OPTION BUTTON
getSelectedOptionInFrame = ' i dont know how to reference the caption of the option button that matches the condition
End If
Next i
End Function
Last edited: