Hi guys, okay 2 questions, please see the below code.
1.) Why in the code below, does my incrementing ScoreInt not work ? need a fresh pair of eyes.
2.) The time in my form when run only displays the time the application was initially run, but does not update... how can i get the time to update every minute correctly ?
Public Class Mathy
Dim ScoreInt As Integer
Dim intHour = Hour(Now)
Dim intMinute = Minute(Now)
Private Sub Mathy_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
LoadRandomValues()
Score.Text = ScoreInt
hhmm.Text = intHour & intMinute
End Sub
Private Sub ButtonGuessAnswer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonGuessAnswer.Click
Static NumberOfGuesses As Integer
Dim Number1 As Double
Dim Number2 As Double
ScoreInt = 0
If String.IsNullOrEmpty(TextBoxAnswer.Text) Then
MessageBox.Show("Please enter a response.")
ElseIf Not IsNumeric(TextBoxAnswer.Text) Then
MessageBox.Show("Wrong.")
Else
Number1 = CDbl(LabelRandomNumber1.Text)
Number2 = CDbl(LabelRandomNumber2.Text)
If CDbl(TextBoxAnswer.Text) = Number1 - Number2 Then
MessageBox.Show("Correct.")
LoadRandomValues() 'reset
NumberOfGuesses = 0
ScoreInt += 1
Else
MessageBox.Show("Wrong.")
ScoreInt += 1
End If
End If
NumberOfGuesses += 1
If NumberOfGuesses = 3 Then
MessageBox.Show("You're out of guesses. The answer was " & Number1 - Number2)
LoadRandomValues()
NumberOfGuesses = 0
End If
ScoreInt = 0
End Sub
Public Sub LoadRandomValues()
Dim generator As New Random
LabelRandomNumber1.Text = generator.Next(1, 100)
LabelRandomNumber2.Text = generator.Next(1, 100)
TextBoxAnswer.Clear()
End Sub
End Class