Hey
Im in the middle of creating a fraction calculator using vb script and i need it too simplify the fractions. Would be great if someone could give me a hand with this its been racking my brains...
This is what i have so far, the bottom part of the script under the btnsimp, is my attempt of getting it to work...
Im in the middle of creating a fraction calculator using vb script and i need it too simplify the fractions. Would be great if someone could give me a hand with this its been racking my brains...
This is what i have so far, the bottom part of the script under the btnsimp, is my attempt of getting it to work...
Code:
<html>
<head>
<title>Fraction Calculator</title>
</head>
<body bg color="DCDCDC">
<center>
<font size="6"><b><i>Fraction Calculator</i></b></font>
<p></p>
<input style="width:20px" id="txt1" type="text" />
<input style="width:20px" id="txt2" type="text" /><p><input style="width:20px" id="txt3" type="text" />
<input style="width:20px" id="txt4" type="text" />
</p>
<p><input id="ans01" type="text" readonly="true"/></p>
<p><input id="ans02" type="text" readonly="true" /></p>
<p></p>
<p><input id="btnp" type="button" value="Plus" />
<input id="btns" type="button" value="Subtract" /></p>
<p><input id="btnd" type="button" value="Divide" />
<input id="btnx" type="button" value="Multiple" /> </p>
<p><input id="btnsimp" type="button" value="Simplify Fraction" /></p>
<p id="ans3"></p>
<p id="ans4"></p>
<script language=vbscript>
sub btnp_OnClick()
ans01.innertext=CInt(txt1.value)*CInt(txt4.value)+CInt(txt3.value)*CInt(txt2.value)
ans02.innertext=CInt(txt3.value)*CInt(txt4.value)
end sub
sub btns_OnClick()
ans01.innertext=CInt(txt1.value)*CInt(txt4.value)-CInt(txt3.value)*CInt(txt2.value)
ans02.innertext=CInt(txt3.value)*CInt(txt4.value)
end sub
sub btnd_OnClick()
ans01.innertext=CInt(txt1.value)*CInt(txt4.value)
ans02.innertext=CInt(txt3.value)*CInt(txt2.value)
end sub
sub btnx_OnClick()
ans01.innertext=CInt(txt1.value)*CInt(txt2.value)
ans02.innertext=CInt(txt3.value)*CInt(txt4.value)
end sub
sub btnsimp_OnClick()
if ans01.value= "even" then
ans01.innertext=CInt(ans01.value/2)
end if
if ans02.value="even" then
ans02.innertext=CInt(ans02.value/2)
end if
end sub
</script>