VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Random number guessing game. You have 10 tries to guess the number that is between 1 and 100.

by Ben Fereris (1 Submission)
Category: Games
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Mon 25th March 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Random number guessing game. You have 10 tries to guess the number that is between 1 and 100.

Rate Random number guessing game. You have 10 tries to guess the number that is between 1 and 100.





Private Sub Command1_Click()
If Abs(Val(Text1.Text) - Star) <= 5 Then
Label1.Caption = "You are five or less numbers away"
ElseIf Abs(Val(Text1.Text) - Star) <= 10 Then
Label1.Caption = "You are ten or less numbers away"
ElseIf Text1.Text = Star Then
Label1.Caption = "Good Job"
ElseIf (Val(Text1.Text) - Star) <= 11 Then
Label1.Caption = "Too Low"
ElseIf (Val(Text1.Text) - Star) >= -11 Then
Label1.Caption = "Too High"
End If
If Label1.Caption = "Good Job" Then
Command2.Enabled = True
End If
Counter = Counter + 1
If Counter = 10 Then
Label1.Caption = "You Lose"
Command2.Enabled = True
Label2.Caption = Star
Counter = 0
End If
If Label2.Visible = True Then
Command2.Visible = True
End If
End Sub

Private Sub Command2_Click()
Unload Form1
Load Form1
Form1.Show
End Sub

Private Sub Command3_Click()
End
End Sub

Private Sub Form_Load()
Randomize
Star = Int((100 * Rnd) + 1)
End Sub

Download this snippet    Add to My Saved Code

Random number guessing game. You have 10 tries to guess the number that is between 1 and 100. Comments

No comments have been posted about Random number guessing game. You have 10 tries to guess the number that is between 1 and 100.. Why not be the first to post a comment about Random number guessing game. You have 10 tries to guess the number that is between 1 and 100..

Post your comment

Subject:
Message:
0/1000 characters