Public Class frmQuiz
Dim numCorrect As Integer
Private Sub btnTakeQuiz_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTakeQuiz.Click
numCorrect = 0
GiveTest(1)
GiveTest(2)
GiveTest(3)
GiveTest(4)
GiveTest(5)
GiveTest(6)
GiveTest(7)
ShowMessage()
End Sub
Sub GiveTest(ByVal numProverb As Integer)
Dim numSaying As Integer
Dim saying As String = ""
Dim answer As String = ""
Dim reply, question As String
GetProverb(numSaying, saying, answer)
question = "(" & numProverb & ") " & saying & " (T/F)"
reply = InputBox(question)
If reply.ToUpper = answer Then
MessageBox.Show("You're right.", "Question " & numProverb)
numCorrect += 1
Else
MessageBox.Show("I'm sorry. You're wrong.", "Question " & numProverb)
End If
End Sub
Sub GetProverb(ByVal which As Integer, ByRef proverb As String,
ByRef truthVal As String)
Select Case which
Case (1)
proverb = InputBox("The squeaky wheel gets the grease.")
truthVal = "T"
Case 2
proverb = "Cry and you cry alone."
truthVal = "T"
Case 3
proverb = "Opposites attract."
truthVal = "F"
Case 4
proverb = "Spare the rod and spoil the child."
truthVal = "F"
Case 5
proverb = "Actions speak louder than words."
truthVal = "T"
Case 6
proverb = "Familiarity breeds contempt."
truthVal = "F"
Case 7
proverb = "Marry in haste, repent at leisure."
truthVal = "T"
End Select
End Sub
Sub ShowMessage()
Select Case numCorrect
Case 7
MessageBox.Show("Perfect. " & numCorrect & " correct")
Case 5, 6
MessageBox.Show("Excellent. " & numCorrect & " correct")
Case Else
MessageBox.Show("You might consider taking Psychology 101. " &
numCorrect & " correct")
End Select
End Sub
End Class