examples of code or syntax for the option button,any example will help.thanks!

Recommended Answers

If opnMale = True Then
iL1 = 3
il2 = 4
ElseIf opnFemale= True Then
iL1 = 2
il2 = 3
End If

Jump to Post

All 3 Replies

If opnMale = True Then
iL1 = 3
il2 = 4
ElseIf opnFemale= True Then
iL1 = 2
il2 = 3
End If

Hi,

Suppose u have to select from Options
"Good" Or "Bad"
Place 2 option buttons of Form and Name then "OptGood" >> Caption >> "Good"
"OptBad" >> Caption >> "Bad"

If u want to Select "Good" then:
OptGood.Value =True

To check which is selected :

If optGood.Value =True Then
Msgbox "Good Selected"
Else
Msgbox "Bad Selected"
End If

Regards
Veena

Better solution is to give al the option buttons the same name.
Make a control array of them.
This way your code is more readable, everything in one event.

Private Sub Option1_Click(Index As Integer)
   Select Case Index
      Case 0
         MsgBox "first"
      Case 1
         MsgBox "second"
      Case 2
         MsgBox "third"
      Case 3
         MsgBox "fourth"
   End Select
End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.