Advertisement
Guest User

Untitled

a guest
Feb 27th, 2012
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System.IO
  2.  
  3. Public Class GameWindow
  4.  
  5.     Dim i, j As Integer
  6.     Dim questions(4, 6) As String
  7.     Dim PlayerName As String
  8.     Dim PlayerScore As Integer
  9.     Dim QuestionsAnswered As Integer
  10.     Dim IntGen As New Random
  11.  
  12.  
  13.  
  14.     Public Function Score()
  15.         If PlayerScore = 0 Then
  16.             PlayerScore = 100
  17.         Else
  18.             PlayerScore = (PlayerScore * 2)
  19.         End If
  20.         lblScore.Text = PlayerScore
  21.         QuestionsAnswered = QuestionsAnswered + 1
  22.     End Function
  23.     Public Function NextQuestion()
  24.  
  25.         If QuestionsAnswered <= 3 Then
  26.  
  27.             Dim SR1 As New StreamReader("K:\College\Unit 14\Assignments\Assignment 2\Questions\easy.txt")
  28.             For i = 0 To 3
  29.                 For j = 0 To 5
  30.                     questions(i, j) = SR1.ReadLine
  31.                 Next
  32.             Next
  33.  
  34.             lblScore.Text = PlayerScore
  35.  
  36.  
  37.             i = IntGen.Next(0, 4)
  38.  
  39.             lblQuestion.Text = questions(i, 0)
  40.             lblAnswerA.Text = questions(i, 1)
  41.             lblAnswerB.Text = questions(i, 2)
  42.             lblAnswerC.Text = questions(i, 3)
  43.             lblAnswerD.Text = questions(i, 4)
  44.  
  45.         ElseIf QuestionsAnswered <= 7 Then
  46.  
  47.             Dim SR2 As New StreamReader("K:\College\Unit 14\Assignments\Assignment 2\Questions\average.txt")
  48.             For i = 0 To 3
  49.                 For j = 0 To 5
  50.                     questions(i, j) = SR2.ReadLine
  51.                 Next
  52.             Next
  53.  
  54.             lblScore.Text = PlayerScore
  55.  
  56.             Dim randintgen As New Random
  57.             i = randintgen.Next(0, 4)
  58.  
  59.             lblQuestion.Text = questions(i, 0)
  60.             lblAnswerA.Text = questions(i, 1)
  61.             lblAnswerB.Text = questions(i, 2)
  62.             lblAnswerC.Text = questions(i, 3)
  63.             lblAnswerD.Text = questions(i, 4)
  64.  
  65.         ElseIf QuestionsAnswered <= 11 Then
  66.  
  67.             Dim SR3 As New StreamReader("K:\College\Unit 14\Assignments\Assignment 2\Questions\hard.txt")
  68.             For i = 0 To 3
  69.                 For j = 0 To 5
  70.                     questions(i, j) = SR3.ReadLine
  71.                 Next
  72.             Next
  73.  
  74.             Dim randintgen As New Random
  75.             i = randintgen.Next(0, 4)
  76.  
  77.             lblQuestion.Text = questions(i, 0)
  78.             lblAnswerA.Text = questions(i, 1)
  79.             lblAnswerB.Text = questions(i, 2)
  80.             lblAnswerC.Text = questions(i, 3)
  81.             lblAnswerD.Text = questions(i, 4)
  82.  
  83.         ElseIf QuestionsAnswered = 12 Then
  84.  
  85.             MsgBox("You Win!")
  86.  
  87.         End If
  88.  
  89.         lblScore.Text = PlayerScore
  90.  
  91.         Dim randintgen As New Random
  92.         i = randintgen.Next(0, 4)
  93.  
  94.         lblQuestion.Text = questions(i, 0)
  95.         lblAnswerA.Text = questions(i, 1)
  96.         lblAnswerB.Text = questions(i, 2)
  97.         lblAnswerC.Text = questions(i, 3)
  98.         lblAnswerD.Text = questions(i, 4)
  99.  
  100.     End Function
  101.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  102.  
  103.  
  104.  
  105.         Dim SR1 As New StreamReader("K:\College\Unit 14\Assignments\Assignment 2\Questions\easy.txt")
  106.         For i = 0 To 3
  107.             For j = 0 To 5
  108.                 questions(i, j) = SR1.ReadLine
  109.             Next
  110.         Next
  111.         NextQuestion()
  112.  
  113.     End Sub
  114.  
  115.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  116.         If questions(i, 5) = "1" Then
  117.             Score()
  118.             MsgBox("Correct")
  119.         Else
  120.             PlayerScore = 0
  121.             MsgBox("Sorry, the correct answer is " & questions(i, questions(i, 5)))
  122.         End If
  123.         NextQuestion()
  124.     End Sub
  125.  
  126.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  127.         If questions(i, 5) = "2" Then
  128.             Score()
  129.             MsgBox("Correct")
  130.         Else
  131.             PlayerScore = 0
  132.             MsgBox("Sorry, the correct answer is " & questions(i, questions(i, 5)))
  133.         End If
  134.         NextQuestion()
  135.     End Sub
  136.  
  137.     Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  138.         If questions(i, 5) = "3" Then
  139.             Score()
  140.             MsgBox("Correct")
  141.         Else
  142.             PlayerScore = 0
  143.             MsgBox("Sorry, the correct answer is " & questions(i, questions(i, 5)))
  144.         End If
  145.         NextQuestion()
  146.     End Sub
  147.  
  148.     Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
  149.         If questions(i, 5) = "4" Then
  150.             Score()
  151.             MsgBox("Correct")
  152.         Else
  153.             PlayerScore = 0
  154.             MsgBox("Sorry, the correct answer is " & questions(i, questions(i, 5)))
  155.         End If
  156.         NextQuestion()
  157.     End Sub
  158. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement