Private Sub Command1_Click()
Dim Question(1 To 3) As String, num(1 To 3) As Integer, X As Integer
Dim a As Integer, Count As Integer, Q As String, Z As Integer
Dim fl1 As Boolean, fl2 As Boolean, fl3 As Boolean 'To exit the code
Question(1) = "What is the capital of Austraila?"
Question(2) = "What is 1+1?"
Question(3) = "Which came first, the chicken or the egg?"
'This is to ensure that each question only appears once
For Count = 1 To 3
num(Count) = Int(Rnd * 3 + 1)
For a = 1 To Count
If a < Count Then
If num(Count) = num(a) Then
Count = Count - 1
Exit For
End If
End If
Z = num(Count)
Next a
Next Count
X = 0
Select Case Z
Case 1
Q = Question(1)
Label1.Caption = Q
opt1.Caption = "Brisbane"
opt2.Caption = "Sydney"
opt3.Caption = "Canberra"
If opt3.Value = True Then
X = X + 1
End If
fl1 = True
Case 2
Label1.Caption = Q
Q = Question(2)
opt1.Caption = "2"
opt2.Caption = "11"
opt3.Caption = "Window"
If opt1.Value = True Then
X = X + 1
End If
fl2 = True
Case 3
Label1.Caption = Q
Q = Question(3)
opt1.Caption = "Chicken"
opt2.Caption = "Egg"
opt3.Caption = "Who Cares?"
If opt3.Value = True Then
X = X + 1
End If
fl3 = True
End Select
If fl1 = True And fl2 = True And fl3 = True Then
MsgBox "scored " & X & " points", vbInformation, "X"
End If
End Sub
|