about option buttons in User form

Posted by Mars on Stack Overflow See other posts from Stack Overflow or by Mars
Published on 2013-11-05T03:29:15Z Indexed on 2013/11/05 3:53 UTC
Read the original article Hit count: 256

Filed under:
|

I have a question:

I need to create a user form that contain that usual OK and Cancel Buttons. It also should contain two sets of Options buttons, each set placed inside a frame. The captions on the first set should be basketball, baseball, football, the captions on the second set should be watch on TV and Go to games. I need to write the event handlers and code in a module so that when the program runs, the user sees the form. If the user makes a couple of choices and clicks OK, he should see a message like "Your favorite sport is basketball, and you usually watch on TV." If the user clicks Cancel, the message "Sorry you don't want to play" should appear.

enter image description here

I think I almost have it working, but I don't know why I cannot successfully execute the Macro.

My Code is :

Option Explicit

Private Sub CommandButton2_Click()


MsgBox ("sorry if you don't want to play")
End Sub

Private Sub commandbuttons_Click()
Dim optbasket As String, optbaseball As String, optfootball As String
Dim optwog As String, optgtg As String

 Select Case True
 Case optbasket
   optbasket = True
 Case optbaseball
   optbaseball = True
 Case optfootball
   optfootball = True
  End Select

If optwog Then
  optwog = True
  Else
  optgtg = True
  End If

btnok = MsgBox("you favorite sport is " & Frame1.Value & "you usually " & Frame2.Value & ",")
End Sub

Private Sub OptionButton1_Click()

End Sub

Private Sub btmcancel_Click()

End Sub

Private Sub btnok_Click()

End Sub

Private Sub Frame1_Click()

End Sub

Private Sub Frame2_Click()

End Sub

Private Sub optbaseball_Click()

End Sub

Private Sub optbasketball_Click()

End Sub

Private Sub optfootball_Click()

End Sub

Thank you very much!!!

© Stack Overflow or respective owner

Related posts about excel-vba

Related posts about user-controls