### Thread: Random Number Guessing Game

1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Nov 2012
Posts
2
Rep Power
0

#### Random Number Guessing Game

I don't understand where I am doing something wrong. The instructions is to create a random application that generates a random number in the range of 1 through 100. If it's too low state "too low, try again" and the same for if it's too high.

(I'm using visual basic)

So I declared my variables and wrote a code for the procedure. I declared x as my integer. Any advice on how to correct it?
Thanks for all help

intNum = rand.Next(100) + 1
For
For x > intNum
MsgBox("Too high, try again")
Next
For x < intNum
MsgBox("Too low, try again")
Next
For x = intNum
MsgBox("You guessed right!")
Next
Next
2. I assume you want to check the value x against intNum. for this you will have to use the IF statement:
e.g.
Code:
```If x > intNum Then
MsgBox("Too high, try again")
ElseIf x < intNum Then
MsgBox("Too low, try again")
Else
MsgBox("You guessed right!")
End If```
Depend at how you have the rest of the code, it may or may not bee needed.
Where do you ask for user input?
3. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Nov 2012
Posts
2
Rep Power
0
Originally Posted by MrFujin
I assume you want to check the value x against intNum. for this you will have to use the IF statement:
e.g.
Code:
```If x > intNum Then
MsgBox("Too high, try again")
ElseIf x < intNum Then
MsgBox("Too low, try again")
Else
MsgBox("You guessed right!")
End If```