While trying to learn excel VBA, I am creating a simple number guessing game. But, my random numbers are predictable. Can
anyone suggest a solution. i.e. if I chooes a random number between 1-100, it is usually 70. A number between 1-1000 is
usually 705 and 1-10,000 is usually 7055. Here is the code:
Public tryCount As Integer
Dim theNum As Integer
Dim uLimit As Integer
Dim numGuess As Integer
Dim r As Integer
r = Int(Rnd())
uLimit = InputBox("Give me an Upper Limit")
theNum = Int(uLimit * Rnd(r))
'theNum = Int((uLimit - 1 + 1) * Rnd + 1)
For tryCount = 1 To 10
numGuess = InputBox("What's My Number ?", Title:="Choose")
If numGuess < theNum Then MsgBox ("Guess Higher")
If numGuess > theNum Then MsgBox ("Guess Lower")
If numGuess = theNum Then winGame
MsgBox ("You didn't get it within 10 tries. My number was " & theNum & " "), Title:="Loser"
MsgBox ("You got it in Only " & tryCount & " tries"), Title:="Winner"
If you like these VB formatting tags please consider sponsoring the author in support of injured Royal Marines
Do I need to force a re-calculate or something?