Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit
- Dim targetNumber, guess, tries
- Randomize
- targetNumber = Int((100 * Rnd()) + 1)
- WScript.Echo "Welcome to the Number Guessing Game!"
- WScript.Echo "I'm thinking of a number between 1 and 100."
- WScript.Echo "Try to guess it!"
- tries = 0
- Do
- guess = InputBox("Enter your guess:")
- If IsNumeric(guess) Then
- guess = CInt(guess)
- If guess >= 1 And guess <= 100 Then
- tries = tries + 1
- If guess < targetNumber Then
- WScript.Echo "Too low! Try again."
- ElseIf guess > targetNumber Then
- WScript.Echo "Too high! Try again."
- Else
- WScript.Echo "Congratulations! You guessed the number in " & tries & " tries!"
- Exit Do
- End If
- Else
- WScript.Echo "Invalid input. Please enter a number between 1 and 100."
- End If
- Else
- WScript.Echo "Invalid input. Please enter a valid number."
- End If
- Loop
- WScript.Quit(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement