Hi guys,
See below. I actually broke this when trying to fix it (trying to add in the return 1,2,3 for the different possibilities), but basically I'm currently struggling with using forms. Using 2 random numbers the user must enter the correct answer for multiplying the random numbers. How can I empty the fields and basically reset the form after a correct answer ? And what is essentially wrong with what i have done ?
Public Class MathLoader
Dim generator As New Random
Dim a1 As Integer = generator.Next(1, 100)
Dim b1 As Integer = generator.Next(1, 100)
Public MathLoader()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Function correctCheck() As Integer
Dim z1 As Double = a1 * b1
Dim x1 As Integer = 0
If TextBox1.Text = "" Then
Label3.Text = "Please enter a value"
Return 2
ElseIf TextBox1.Text = z1 Then
Label3.Text = "Correct !"
ans1.Text = z1
Beep()
Return 1
Else
Label3.Text = "Wrong..."
Return 3
End If
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Try
ran1.Text = a1
ran2.Text = b1
If ans1.Text = "" Then
MessageBox.Show("Please enter a response")
ElseIf ans1.Text <> "" Then
For index = 1 To 3
If Me.correctCheck() = 1 Then
MessageBox.Show("Complete")
ElseIf Me.correctCheck() = 2 Then
MessageBox.Show("2")
ElseIf Me.correctCheck() = 3 Then
MessageBox.Show("3")
Else
MessageBox.Show("4")
End If
Next
MessageBox.Show("You're out of guesses")
End If
'Catch e As Exception
' MessageBox.Show(e.ToString)
'End Try
End Sub
End Class