Imports System.IO
Public Class GameWindow
Dim i, j As Integer
Dim questions(4, 6) As String
Dim PlayerName As String
Dim PlayerScore As Integer
Dim QuestionsAnswered As Integer
Dim IntGen As New Random
Public Function Score()
If PlayerScore = 0 Then
PlayerScore = 100
Else
PlayerScore = (PlayerScore * 2)
End If
lblScore.Text = PlayerScore
QuestionsAnswered = QuestionsAnswered + 1
End Function
Public Function NextQuestion()
If QuestionsAnswered <= 3 Then
Dim SR1 As New StreamReader("K:\College\Unit 14\Assignments\Assignment 2\Questions\easy.txt")
For i = 0 To 3
For j = 0 To 5
questions(i, j) = SR1.ReadLine
Next
Next
lblScore.Text = PlayerScore
i = IntGen.Next(0, 4)
lblQuestion.Text = questions(i, 0)
lblAnswerA.Text = questions(i, 1)
lblAnswerB.Text = questions(i, 2)
lblAnswerC.Text = questions(i, 3)
lblAnswerD.Text = questions(i, 4)
ElseIf QuestionsAnswered <= 7 Then
Dim SR2 As New StreamReader("K:\College\Unit 14\Assignments\Assignment 2\Questions\average.txt")
For i = 0 To 3
For j = 0 To 5
questions(i, j) = SR2.ReadLine
Next
Next
lblScore.Text = PlayerScore
Dim randintgen As New Random
i = randintgen.Next(0, 4)
lblQuestion.Text = questions(i, 0)
lblAnswerA.Text = questions(i, 1)
lblAnswerB.Text = questions(i, 2)
lblAnswerC.Text = questions(i, 3)
lblAnswerD.Text = questions(i, 4)
ElseIf QuestionsAnswered <= 11 Then
Dim SR3 As New StreamReader("K:\College\Unit 14\Assignments\Assignment 2\Questions\hard.txt")
For i = 0 To 3
For j = 0 To 5
questions(i, j) = SR3.ReadLine
Next
Next
Dim randintgen As New Random
i = randintgen.Next(0, 4)
lblQuestion.Text = questions(i, 0)
lblAnswerA.Text = questions(i, 1)
lblAnswerB.Text = questions(i, 2)
lblAnswerC.Text = questions(i, 3)
lblAnswerD.Text = questions(i, 4)
ElseIf QuestionsAnswered = 12 Then
MsgBox("You Win!")
End If
lblScore.Text = PlayerScore
Dim randintgen As New Random
i = randintgen.Next(0, 4)
lblQuestion.Text = questions(i, 0)
lblAnswerA.Text = questions(i, 1)
lblAnswerB.Text = questions(i, 2)
lblAnswerC.Text = questions(i, 3)
lblAnswerD.Text = questions(i, 4)
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim SR1 As New StreamReader("K:\College\Unit 14\Assignments\Assignment 2\Questions\easy.txt")
For i = 0 To 3
For j = 0 To 5
questions(i, j) = SR1.ReadLine
Next
Next
NextQuestion()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If questions(i, 5) = "1" Then
Score()
MsgBox("Correct")
Else
PlayerScore = 0
MsgBox("Sorry, the correct answer is " & questions(i, questions(i, 5)))
End If
NextQuestion()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If questions(i, 5) = "2" Then
Score()
MsgBox("Correct")
Else
PlayerScore = 0
MsgBox("Sorry, the correct answer is " & questions(i, questions(i, 5)))
End If
NextQuestion()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If questions(i, 5) = "3" Then
Score()
MsgBox("Correct")
Else
PlayerScore = 0
MsgBox("Sorry, the correct answer is " & questions(i, questions(i, 5)))
End If
NextQuestion()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
If questions(i, 5) = "4" Then
Score()
MsgBox("Correct")
Else
PlayerScore = 0
MsgBox("Sorry, the correct answer is " & questions(i, questions(i, 5)))
End If
NextQuestion()
End Sub
End Class