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.

Wednesday 21 January 2015

A scientific calculator code in VB Script

<script language="vbscript">
function back()
m=document.fr.t1.value
q=(len(m)-1)
document.fr.t1.value=left(m,q)
end function



function res()
document.fr.t1.value=eval(document.fr.t1.value)
end function

function co()
if document.fr.ra(0).checked then
pw=document.fr.t1.value
ow=(pw*3.14159265)/180
document.fr.t1.value=Cos(ow)
elseif documenr.fr.ra(1).checked then
document.fr.t1.value=Cos(document.fr.t1.value)
end if
end function

function mi()
document.fr.t1.value=1/(document.fr.t1.value)
end function

function ta()
if document.fr.ra(0).checked then
pq=document.fr.t1.value
oq=(pq*3.14159265)/180
document.fr.t1.value=Tan(oq)
elseif documenr.fr.ra(1).checked then
document.fr.t1.value=Tan(document.fr.t1.value)
end if
end function

function math(val)
document.fr.t1.value=document.fr.t1.value+val
end function

function lo()
document.fr.t1.value=log(document.fr.t1.value)
end function

function sqr()
if document.fr.t1.value>0 then
document.fr.t1.value=(document.fr.t1.value)^(1/2)
elseif document.fr.t1.value<0 then
z=(((document.fr.t1.value)*(-1))^(1/2))
document.fr.t1.value=z & "i"
end if
end function

function si()
if document.fr.ra(0).checked then
p=document.fr.t1.value
o=(p*3.14159265)/180
document.fr.t1.value=Sin(o)
elseif documenr.fr.ra(1).checked then
document.fr.t1.value=Sin(document.fr.t1.value)
end if
end function

function factorial()
t=1
l=document.fr.t1.value
for e=1 to l
t=t*e
next
document.fr.t1.value=t
end function

function clear
document.fr.t1.value=""
end function
</script>
<body bgcolor="silver">
<form name="fr">
<center>

<FONT SIZE="20">Calculator</FONT>

<table  background="C:\Documents and Settings\web\Desktop\fedf.jpg" border="5" 

bordercolor="black" cellpadding="5" cellspacing="5">

<tr>
<td colspan="4"><input type="text" name="t1" size="30">
</tr>
<tr>
<td colspan="4"><font size="1">Angle:- 
<input type="radio" name="ra">In Degree 
<input type="radio" name="ra">In Radian</font></td>
<tr>
<td><input type="button" onclick="math('1')" value="1">
<td width="50"><input type="button" onclick="math('2')" value="2">
<td><input type="button" onclick="math('3')" value="3">
<td><input type="button" onclick="math('+')" value="+">
</tr>
<tr>
<td><input type="button" onclick="math('4')" value="4">
<td><input type="button" onclick="math('5')" value="5">
<td><input type="button" onclick="math('6')" value="6">
<td><input type="button" onclick="math('-')" value="-">
</tr>
<tr>
<td><input type="button" onclick="math('7')" value="7">
<td><input type="button" onclick="math('8')" value="8">
<td><input type="button" onclick="math('9')" value="9">
<td><input type="button" onclick="math('*')" value="*">
</tr>
<tr>
<td><input type="button" onClick="math('.')" value=".">
<td><input type="button" onclick="math('0')" value="0">
<td><input type="button" onClick="sqr()" value="sqrt">

<td><input type="button" onclick="math('/')" value="/">
<tr>
<td><input type="button" onClick="si()" value="sin">
<td><input type="button" onClick="co()" value="cos">
<td><input type="button" onClick="ta()" value="tan">
<td><input type="button" onClick="lo()" value="log">
<tr>
<td><input type="button" onClick="mi()" value="1/x">
<td><input type="button" onClick="math('(')" value="(">
<td><input type="button" onClick="math(')')" value=")">
<td><input type="button" onclick="factorial()" value="!">
<tr>
<td colspan="2"><input type="button" onclick="back()" value="Backspace">
<td><input type="button" onClick="clear()" value="C">
<td><input type="button" onClick="res()" value="=">
</table>

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

For more visit:-www.virusmakingcodes.blogspot.com