Option Explicit
Dim kaitou As Integer
Dim seikaisu As Integer
Dim mondai As Integer
Private Sub CommandButton1_Click()
OptionButton1.Enabled = False
OptionButton2.Enabled = False
OptionButton3.Enabled = False
CommandButton1.Enabled = False
If kaitou = Worksheets(“sheet2”).Cells(mondai + 1, 6) Then
Label3.Caption = “○”
seikaisu = seikaisu + 1
Else
Label3.Caption = “×”
End If
CommandButton2.Enabled = True
If Label2.Caption = 5 Then
Label4.Caption = “5問中” & seikaisu & “問正解しました!”
CommandButton2.Enabled = False
End If
If mondai = 5 Then
CommandButton2.Enabled = False
End If
End Sub
Private Sub CommandButton2_Click()
OptionButton1.Value = False
OptionButton2.Value = False
OptionButton3.Value = False
Label3.Caption = “”
OptionButton1.Enabled = True
OptionButton2.Enabled = True
OptionButton3.Enabled = True
CommandButton1.Enabled = False
CommandButton2.Enabled = False
mondai = mondai + 1
Label2.Caption = mondai
TextBox1.Text = Worksheets(“sheet2”).Cells(mondai + 1, 2)
OptionButton1.Caption = Worksheets(“sheet2”).Cells(mondai + 1, 3)
OptionButton2.Caption = Worksheets(“sheet2”).Cells(mondai + 1, 4)
OptionButton3.Caption = Worksheets(“sheet2”).Cells(mondai + 1, 5)
CommandButton2.Enabled = False
End Sub
Private Sub OptionButton1_Click()
kaitou = 1
CommandButton1.Enabled = True
End Sub
Private Sub OptionButton2_Click()
kaitou = 2
CommandButton1.Enabled = True
End Sub
Private Sub OptionButton3_Click()
kaitou = 3
CommandButton1.Enabled = True
End Sub
Private Sub TextBox1_Change()
End Sub
Private Sub UserForm_initialize()
seikaisu = 0
mondai = 1
Label2.Caption = 1
TextBox1.Text = Worksheets(“sheet2”).Cells(2, 2)
OptionButton1.Caption = Worksheets(“sheet2”).Cells(2, 3)
OptionButton2.Caption = Worksheets(“sheet2”).Cells(2, 4)
OptionButton3.Caption = Worksheets(“sheet2”).Cells(2, 5)
CommandButton2.Enabled = False
End Sub