ZoomCities IT Community Webmaster Forum

Full Version: Visual basic 6 Help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi guys. i was wondering if someone could help me. I've got an assignment to do for Information & Software Technology and I have to make a game which automatically thinks of a secret number and the computer has to tell you if it's higher or lower each time you guess. All I can think of is:

dim secret number as integer

Which is obviously just a fraction of the code needed.

Wondering if anyone could help. ThanksSmile

Code:
Dim secretnumber As Integer

Randomize
secretnumber = Int((HighestValue - LowestValue + 1) * Rnd) + LowestValue


so theres your secret number.

then you need some kind of textbox called txtGuess where the user enters there guess and a button. on the button click you would need something like:

Code:
If txtGuess.Text = secretnumber Then
   MsgBox("Correct!")
End If

If txtGuess.Text < secretnumber Then
   MsgBox("Go Higher")
Else If txtGuess.Text > secretnumber Then
   MsgBox("Go Lower")
End If


needs some work, but good luck

I didn't know you could just type in randomise - cool! Thanks goughy000.
well the actual random number is created by Rnd but the randomize gives Rnd a new random number, otherwise it always returns the same random numbers.

i took most of that code of another site from a google search.
lols - for some reason i couldn't find anything. Anyway thanks again!
Reference URL's