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

No comments:

Post a Comment