Sunday 14 June 2015

Guess the number Game in VB Script

<h1 align="center">Guess The Number</h1>
<script language="VBScript">
randomize
d=Int((100 * Rnd) + 1)
c=d
for i=1 to 50
x=inputbox("Enter a number")
if cInt(x)=c then
document.write("Congrats you have guessed the right number and you made"&i&" guesses.")
exit for
elseif cInt(x)>c then
msgbox("Your number is greater")
elseif cInt(x)<c then
msgbox("Your number is lower")
end if
next
</script>

Instructions :-
  1. Copy this code and paste it in notepad
  2. Save it with an extension .html
  3. Run it on Internet Explorer only.It might not work on other browser as they do not support vb language.

No comments:

Post a Comment