Code the click event of the Play Game button to do the following
i. Generate a random integer between 1 and 100
ii. Code a loop that will end when the user guesses the number or 10 guesses have failed to find the number.
iii. Use an inputbox function so that the user can enter each guess.
iv. If the user does not enter an integer number display an error messagebox, show the answer, and exit the loop. If the user enters a number outside the range of 0 – 100 display an error messagebox, show the answer, and exit the loop.
v. Show each guess in the Guesses Label using concatenation.
vi. If the guess is incorrect change the message portion of the InputBox function to “Guess Higher” or “Guess Lower”. Hint: Only use one InputBox – not three different ones.
vii. Use a messagebox to inform the user that the correct number has been guessed or that ten guesses have failed to guess the number.

My answer so far:
Private Sub btnPlay_Click(sender As Object, e As EventArgs) Handles btnPlay.Click

            Dim ObjRandom As New Random
    Dim intGuesses As Integer
    Dim intcount As Integer
    Dim value As Integer = CInt(Int((100 * Rnd()) + 1))

I'll just give you some important parts

For inputbox, the user's input will be stored in the variable input_value

Dim input_value as String
input_value = InputBox("Enter a number: ")

Then to check if input_value is an integer

Dim test_integer as Integer
if Integer.TryParse(input_value,test_integer) then
    'What to do if the test returns true?
else
    'What if it is false;the input is not an integer?
end if

Integer.TryParse(source,destination)
What it does is it tries to convert the source value to an integer and puts it in the destination. if it succeeds then it returns TRUE.
that's why it is used in a conditional statement like the sample above.

As for messagebox, it is very simple

Msgbox("Please try again")

It is a simple programming excercise so everything else you can do it easily
by using a loop and conditional statements. Have fun programming.

Private Sub btnPlay_Click(sender As Object, e As EventArgs) Handles btnPlay.Click

    ' Generate random value between 1 and 100.
    Dim ObjRandom As New Random
    Dim intGuesses As Integer
    Dim intcount As Integer
    Dim input_value As String
    Dim test_integer As Integer
    Dim value As Integer = CInt(Int((100 * Rnd()) + 1))

input_value = InputBox("Enter a number: ")

   If Integer.TryParse(input_value, test_integer) Then
        'What to do if the test returns true?
    Else
        'What if it is false;the input is not an integer?
    End If

Like this>? Also I need a help about loop

For something like this with a pre-determined number of guesses and a sentinel value (Correct guess exits) you would want to use a do-loop while(X <=10 And Correct = False) You would declare X prior to the loop as an Integer with a value of 0 and Correct prior to the loop as a Boolean with the value False. You would increment X += 1 at the bottom of the loop just above the Loop While statement. This is a really simple programming exercise and if you just concentrate on the logic going from top to bottom you shouldn't have any problems getting it right.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.