'Assignment 6B - Fahad Atif
Option Explicit
Private intCounter1 As Integer, intCounter2 As Integer, intQuestionCounter As Integer
Private Sub cmdDone_Click()
Unload Me
End Sub
Private Sub cmdQuestion_Click()
Dim strTextEntered As String, strConvertedTextEntered
intQuestionCounter = intQuestionCounter + 1
If intQuestionCounter = 1 Then
strTextEntered = InputBox("Who was the first prime minister of Canada?", "Question #1") 'Gives the user an input box so they can respond to a given question
strConvertedTextEntered = StrConv(strTextEntered, vbLowerCase) 'Converts the users text to lower case
If strConvertedTextEntered = "sir john a. macdonald" Then
MsgBox "Your answer is correct!"
intCounter1 = intCounter1 + 1 'Adds 1 to the number of questions attempted.
intCounter2 = intCounter2 + 1 'Adds 1 to the number of questions answered correctly.
ElseIf strConvertedTextEntered = "" Then
intCounter1 = intCounter1 + 1 'Adds 1 to the number of questions attempted.
ElseIf strConvertedTextEntered <> "sir john a. macdonald" Then
MsgBox "Your answer is incorrect."
intCounter1 = intCounter1 + 1 'Adds 1 to the number of questions attempted.
End If
End If
If intQuestionCounter = 2 Then
strTextEntered = InputBox("Which is the most Westerly great lake?", "Question #2") 'Gives the user an input box so they can respond to a given question
strConvertedTextEntered = StrConv(strTextEntered, vbLowerCase) 'Converts the users text to lower case
If intCounter1 = 1 And strConvertedTextEntered = "lake superior" Then
MsgBox "Your answer is correct!"
intCounter1 = intCounter1 + 1 'Adds 1 to the number of questions attempted.
intCounter2 = intCounter2 + 1 'Adds 1 to the number of questions answered correctly.
ElseIf strConvertedTextEntered = "" Then
intCounter1 = intCounter1 + 1 'Adds 1 to the number of questions attempted.
ElseIf intCounter1 = 1 And strConvertedTextEntered <> "lake superior" Then
MsgBox "Your answer is incorrect."
intCounter1 = intCounter1 + 1 'Adds 1 to the number of questions attempted.
End If
End If
If intQuestionCounter > 2 Then
MsgBox "No more questions available."
End If
lblNumAttempted.Caption = intCounter1
lblNumAnsweredCorrectly.Caption = intCounter2
End Sub
Private Sub Form_Load()
intQuestionCounter = 0
intCounter1 = 0
intCounter2 = 0
End Sub