by Morbid Florist (1 Submission)
Category: Math/Dates
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 14th September 2004
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Computer generates random number, 1 - 100, user inputs guess, if guess is too high/low, it is printed on screen, as is if the answer is
API Declarations
Dim RandomNumber As Integer
-------------------------------------
Place one text box named "txtguess"
Place three command buttons named "cmdaccept", "cmdexit" and "cmdstart"
Place one label named "lblresponse"
Start button generates random number, exit button exits, accept button becomes visible after user has input number.
End
End Sub
Private Sub cmdaccept_Click()
lblresponse.Caption = " "
guess = Val(txtguess.Text)
If RandomNumber > guess Then lblresponse.Caption = "Too Low"
If RandomNumber < guess Then lblresponse.Caption = "Too High"
If RandomNumber = guess Then lblresponse.Caption = "Correct"
cmdstart.Visible = True
End Sub
Private Sub cmdstart_Click()
Randomize Timer
RandomNumber = (Rnd * 100) + 1
cmdaccept.Visible = True
cmdstart.Visible = False
End Sub
Private Sub Form_Load()
cmdaccept.Visible = False
End Sub
No comments have been posted about Computer generates random number, 1 - 100, user inputs guess, if guess is too high/low, it is print. Why not be the first to post a comment about Computer generates random number, 1 - 100, user inputs guess, if guess is too high/low, it is print.