hey all,
i've got a new issue with a program that allows the user to enter a number and then that number is checked against a random number that the PC chooses. Here's the code:
Private Sub xCalcButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xCalcButton.Click
'show the random number
Dim randomnum As Integer
Dim randomGenerator As New Random
randomnum = randomGenerator.Next(1, 51) 'give the number
Dim userent As String
Dim usernum As Integer
Dim chancecount As Integer = 0
Dim isConverted As Boolean
userent = Me.xEnterTextBox.Text
'go as long as they enter a number
Do While userent <> String.Empty
'convert the sales number
isConverted = Integer.TryParse(userent, usernum)
If isConverted And usernum < randomnum Then
chancecount = chancecount + 1
Me.xAnswerLabel.Text = "Oops, too low. Go a little higher"
ElseIf usernum > randomnum Then
chancecount = chancecount + 1
Me.xAnswerLabel.Text = "Whoa! Whoa! You're guessing a little too high now."
End If
Loop
If usernum = randomnum Then
Me.xAnswerLabel.Text = "Congratulations, you have selected the correct number which is, " + Convert.ToString(usernum)
Else
End If
End Sub
I know i'm on the brink but what exactly am I missing? should i make the random constant or something?