Sunday, 14 June 2015

Timer in VB Script

<script language="vbscript">
alert("Click to start timer.")

x=Timer
document.write(x)
alert ("Click to end timer.")
y=Timer-x

alert ("Elapsed Seconds: " & y)

</script>

Instructions :-
  1. Copy this above 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.

HTML Form and VB Script

<script language="vbscript">
sub abc
x=document.fr.t1.value
if document.fr.ra(0).checked then
a=5000
elseif document.fr.ra(1).checked then
a=7000
end if
b="0"
if document.fr.ca(0).checked then
b=b+500
end if
if document.fr.ca(1).checked then
b=b+350
end if
if document.fr.ca(2).checked then
b=b+200
end if
z=a+b
q=document.fr.li.selectedindex
if q=0 then
z=z-100
elseif q=1 then
z=z-50
end if
document.fr.t2.value=ucase(x)&" you have to pay Rs."&z
end sub
</script>
<form name="fr">
<h1 align="center">Modern School,Antarctica</h1>
Enter name<input type="text" name="t1"><br>
Day Boarding<input type="radio" name="ra">
Hostel<input type="radio" name="ra"><br>
Cantine<input type="checkbox" name="ca">
Sports<input type="checkbox" name="ca">
Library<input type="checkbox" name="ca"><br>
Payment Option<select name="li">
<option>Credit Card
<option>Cash
</select><br>
<input type="button" value="Bill" onClick="abc">
<input type="text" name="t2" size="100">
</form>

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.

Diamond Shape IN VB Script

 <script language="vbscript">
for i=0 to 5
for j=i to 5
document.write("_")
next
for k=1 to ((i*2)+1)
document.write("*")
next
document.write("<br>")
next
for x=5 to 0 step-1
for y=x to 5
document.write("_")
next
for z=1 to ((x*2)+1)
document.write("*")
next
document.write("<br>")
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.

Shapes and patterns using VB Script

<script language="vbscript">
for a=1 to 5
for b=1 to 5
if  a=1 OR b=1 OR b=5 OR a=3 then
document.write("#")
else
document.write(" . ")
end if
next
document.write("<br>")
next

document.write("<hr>")

for i=1 to 5
for j=1 to 5
if i=1 OR j=1 OR i=5 then
document.write("#")
else
document.write(" . ")
end if
next
document.write("<br>")
next

document.write("<hr>")

for p=1 to 5
for q=1 to 5
if p=1 OR p=5 OR p+q=6 then
document.write("#")
else
document.write(" . ")
end if
next
document.write("<br>")
next

document.write("<hr>")

for a=1 to 5
for b=1 to 5
if  a+b=6 OR a=b then
document.write("#")
else
document.write(" . ")
end if
next
document.write("<br>")
next

document.write("<hr>")

for a=1 to 5
for b=1 to 5
if  a=1 OR b=3 then
document.write("#")
else
document.write(" . ")
end if
next
document.write("<br>")
next

document.write("<hr>")


</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.

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.