fork download
  1. Imports System
  2.  
  3. Module Module1
  4. Const QUESTION_TYPE_ADDITION As Integer = 0
  5. Const QUESTION_TYPE_SUBTRACTION As Integer = 1
  6. Const QUESTION_TYPE_MULTIPLICATION As Integer = 2
  7. Const QUESTION_TYPE_DIVISION As Integer = 3
  8.  
  9. Public Class Test
  10. Private Dim RandomGenerator As Random
  11. Private Dim Question As String
  12. Private Dim Answer As Integer
  13. Private Dim Score As Integer
  14.  
  15. Private Sub GenerateQuestion()
  16. ' Get the question type
  17. Dim QuestionType As Integer = RandomGenerator.Next(0, 3)
  18. Dim FirstNumber As Integer = RandomGenerator.Next(1, 100)
  19. Dim SecondNumber As Integer = RandomGenerator.Next(1, 100)
  20.  
  21. Select Case QuestionType
  22. Case QUESTION_TYPE_ADDITION
  23. Question = FirstNumber & " + " & SecondNumber & " = ?"
  24. Answer = FirstNumber + SecondNumber
  25.  
  26. Case QUESTION_TYPE_SUBTRACTION
  27.  
  28. Case QUESTION_TYPE_MULTIPLICATION
  29.  
  30. Case QUESTION_TYPE_DIVISION
  31.  
  32. Case Else
  33. Console.WriteLine("Something went wrong. ;-;")
  34. End Select
  35. End Sub
  36.  
  37. Private Sub AskQuestion()
  38. Console.Clear()
  39. Console.WriteLine(Question)
  40.  
  41. Dim Entry As Integer = Console.Read()
  42. If Entry = Answer Then
  43. Console.WriteLine("Correct!")
  44. Score += 1
  45. Else
  46. Score -= 1
  47. End If
  48. End Sub
  49.  
  50. Public Shared Sub Main()
  51. Dim index as Integer = 1
  52.  
  53. While index <> 10
  54. GenerateQuestion()
  55. AskQuestion()
  56.  
  57. index += 1
  58. End While
  59.  
  60. Console.WriteLine("Your score is " & Score)
  61. End Sub
  62. End Class
  63. End Module
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Visual Basic.Net Compiler version 0.0.0.5943 (Mono 3.8 - tarball)
Copyright (C) 2004-2010 Rolf Bjarne Kvinge. All rights reserved.

/home/X08UdF/prog.vb (54,22) : error VBNC30369: Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class.
/home/X08UdF/prog.vb (55,17) : error VBNC30369: Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class.
/home/X08UdF/prog.vb (60,46) : error VBNC30369: Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class.
There were 3 errors and 0 warnings.
Compilation took 00:00:00.9294670
stdout
Standard output is empty