-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnumber_guesser.vbs
More file actions
29 lines (23 loc) · 816 Bytes
/
number_guesser.vbs
File metadata and controls
29 lines (23 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
' Number Guessing Game in VBS
minNumber = 1
maxNumber = Rnd()
randomNumber = Int(Rnd() * (maxNumber - minNumber + 1)) + minNumber
guessCount = 0
WScript.Echo "Guess a number between " & minNumber & " and " & maxNumber & ":"
Do While True
guessCount = guessCount + 1
guess = InputBox("Guess #" & guessCount)
If IsNumeric(guess) Then
If CInt(guess) = randomNumber Then
WScript.Echo "Congratulations! You guessed the number in " & guessCount & " tries."
Exit Do
ElseIf CInt(guess) < randomNumber Then
WScript.Echo "Too low. Try again."
Else
WScript.Echo "Too high. Try again."
End If
Else
WScript.Echo "Invalid input. Please enter a number."
End If
Loop
' By Johann Kramer 2024