So I need to generate a new random number after its completed and I've already gotten the number to be correct and clear the form but I don't get how to create a new random number because whenever I press "New Game" it clears it but when I put the same number it says "Correct!" again. I think it has to do with me putting the variables in the public class but I'm not sure.
Code:
Public Class GuessNumberForm
Dim rand As New Random()
Dim randnum As Integer = rand.Next(1, 101)
Dim guess As Integer
Private Sub enterButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles enterButton.Click
guess = CInt(Val(guessTextBox.Text))
If guess = randnum Then
outputLabel.Text = "Correct!"
newGameButton.Enabled = True
ElseIf guess > randnum Then
outputLabel.Text = "Too high..."
ElseIf guess < randnum Then
outputLabel.Text = "Too low..."
End If
End Sub
Private Sub newGameButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles newGameButton.Click
Dim randgen As New Random()
Dim randnumgen As Integer = rand.Next(1, 101)
outputLabel.Text = ""
guessTextBox.Text = ""
End Sub
End Class ' GuessNumberForm