I have searched an found this type (similar) question asked, however, I have written the code and it is only half way working.
The project is a Random Number guessing solution.
The project call for a solution that will generate random #'s from 1-50, and allows the User to guess what the number is 10x's before it the solution displays a message box that tells the user what the number was. The solution also is required to display a message box either telling the user to guess higher or lower, or if the user guesses correct a message displays - "you Win".
Like I said I have it written and it is partly working. the probelm is it gets "stuck after the first attempt (message box will not close)and only repeats 5 times instead of 10.
I searched all night last night, found some help here, but I need to have this done by the Morning or take a partial score for homework assignment and leave it as is.
CODE
Private Sub CheckButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckButton1.Click
' Generates a random number as stores it in a variable named computerchoice
Dim computerchoice As Integer
Dim randomGenerator As New Random
computerchoice = randomGenerator.Next(1, 50)
Dim userguess As Integer
Dim guessCount As Integer
For guessCount = 1 To 10 Step 1
Integer.TryParse(Me.xGuessTextBox1.Text, userguess)
' If the User Guess matches the computer choice message box displays "You Win"
If userguess = computerchoice Then
MessageBox.Show("You Win", "Congratulations", MessageBoxButtons.OK)
End If
' If the user Guess is lower than the computer choice
If userguess < computerchoice Then
MessageBox.Show("Guess Higher", "Guess Again", MessageBoxButtons.OKCancel)
guessCount = guessCount + 1
xGuessTextBox1.Text = String.Empty 'userguess.ToString
End If
If userguess > computerchoice Then
MessageBox.Show("Guess Lower", "Guess Again", MessageBoxButtons.OKCancel)
guessCount = guessCount + 1
xGuessTextBox1.Text = String.Empty ' userguess.ToString
End If
Next guessCount
MessageBox.Show(Convert.ToString(computerchoice), "The Number Was")
xGuessTextBox1.Text = userguess.ToString
End Sub