Public Class Form3
Dim RandomClass As New Random
Dim symbole As Integer
Dim Answers As Integer
Public Wrong_Answer As Integer
Public Total_Correct As Integer
Public Lifes As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
check()
End Sub
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
lblname.Text = username
randomize()
End Sub
Sub randomize()
Int(Rnd() * 25)
TextBox1.Text = ""
textbox2.Text = (RandomClass.Next(1, 10))
textbox3.Text = (RandomClass.Next(1, 10))
symbole = CInt(Int(Rnd() * 4) + 1)
If symbole = 1 Then label2.Text = ("+")
If symbole = 2 Then label2.Text = ("-")
If symbole = 3 Then label2.Text = ("*")
If symbole = 4 Then label2.Text = ("/")
End Sub
Sub check()
If symbole = 1 Then check1()
If symbole = 2 Then check2()
If symbole = 3 Then check3()
If symbole = 4 Then check4()
End Sub
Sub Check1()
Dim variable1 As Double
Double.TryParse(TextBox1.Text, variable1)
Dim variable2 As Double
Double.TryParse(textbox2.Text, variable2)
Dim answers As Double = variable1 + variable2
If variable1 + variable2 = answers Then
Msgboxcor()
Else
If variable1 + variable2 <> answers Then Msgboxinc()
End If
End Sub
Sub check2()
Dim variable1 As Double
Double.TryParse(TextBox1.Text, variable1)
Dim variable2 As Double
Double.TryParse(textbox2.Text, variable2)
Dim answers As Double = variable1 - variable2
If variable1 - variable2 = answers Then
Msgboxcor()
Else
Msgboxinc()
End If
End Sub
Sub check3()
Dim variable1 As Double
Double.TryParse(TextBox1.Text, variable1)
Dim variable2 As Double
Double.TryParse(textbox2.Text, variable2)
Dim answers As Double = variable1 * variable2
If variable1 * variable2 = answers Then
Msgboxcor()
Else
Msgboxinc()
End If
End Sub
Sub check4()
Dim variable1 As Double
Double.TryParse(TextBox1.Text, variable1)
Dim variable2 As Double
Double.TryParse(textbox2.Text, variable2)
Dim answers As Double = variable1 * variable2
If variable1 * variable2 = answers Then
Msgboxcor()
Else
Msgboxinc()
End If
End Sub
Sub Msgboxcor()
MsgBox("Correct")
Total_Correct = +1
randomize()
End Sub
Sub Msgboxinc()
MsgBox("Incorrect")
Wrong_Answer = +1
Lifes = +1
If Lifes = 2 Then Close()
End Sub
End Class