Advertisement
SillyLilFemboy

cool lil thing i made x3

Apr 26th, 2024
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VBScript 1.05 KB | Cybersecurity | 0 0
  1. Option Explicit
  2.  
  3. Dim targetNumber, guess, tries
  4.  
  5.  
  6. Randomize
  7. targetNumber = Int((100 * Rnd()) + 1)
  8.  
  9. WScript.Echo "Welcome to the Number Guessing Game!"
  10. WScript.Echo "I'm thinking of a number between 1 and 100."
  11. WScript.Echo "Try to guess it!"
  12.  
  13. tries = 0
  14. Do
  15.    
  16.     guess = InputBox("Enter your guess:")
  17.  
  18.    
  19.     If IsNumeric(guess) Then
  20.         guess = CInt(guess)
  21.         If guess >= 1 And guess <= 100 Then
  22.            
  23.             tries = tries + 1
  24.             If guess < targetNumber Then
  25.                 WScript.Echo "Too low! Try again."
  26.             ElseIf guess > targetNumber Then
  27.                 WScript.Echo "Too high! Try again."
  28.             Else
  29.                
  30.                 WScript.Echo "Congratulations! You guessed the number in " & tries & " tries!"
  31.                 Exit Do
  32.             End If
  33.         Else
  34.             WScript.Echo "Invalid input. Please enter a number between 1 and 100."
  35.         End If
  36.     Else
  37.         WScript.Echo "Invalid input. Please enter a valid number."
  38.     End If
  39. Loop
  40.  
  41. WScript.Quit(0)
Tags: #meow
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement