Simple Calculator Using VBScript!!
Update: June 25, 2012:
By default this program will run on the Internet Explorer Browser only. If you want to run in Firefox, you would want to add add-on to support VBScript. Since VBScript is Microsoft's Native Scripting language only IE will be able to execute it by default. I saw comments stating that it doesn't work. So guys try running in IE, it will work. Javascript is the scripting language that supports almost all browsers.
Source Code:
<html>
<head>
<title>A simple VBScript Calculator</title>
<script language = "VBscript">
Dim Novalue
Novalue = 0
Function Math(val)
If (Novalue = 1) Then
document.f.ans.value = ""
Novalue = 0
End If
document.f.ans.value=document.f.ans.value+val
End Function
Function equals()
document.f.ans.value=eval(document.f.ans.value)
Novalue = 1
End Function
Function Clear()
document.f.ans.value = ""
End Function
</script>
</head>
<body>
<form name ="f">
<center>
<BR>
<table width="184" height="180" border="2">
<tr>
<td colspan="4"><input name = "ans" type = "text" size="0"></td>
</tr>
<tr> <td width="41"><input type = "button" value = " 7 " name = "7" onclick = "Call Math('7')"></td>
<td width="41"><input type = "button" value = " 8 " name = "8" onclick = "Call Math('8')"></td>
<td width="41"><input type = "button" value = " 9 " name = "9" onclick = "Call Math('9')"></td>
<td width="41"><input type = "button" value = " / " name = "/" onclick = "Call Math('/')"></td>
</tr>
<tr> <td><input type = "button" value = " 4 " name = "4" onclick = "Call Math('4')"></td>
<td><input type = "button" value = " 5 " name = "5" onclick = "Call Math('5')"></td>
<td><input type = "button" value = " 6 " name = "6" onclick = "Call Math('6')"></td>
<td><input type = "button" value = " * " name = "*" onclick = "Call Math('*')"></td> </tr>
<tr> <td><input type = "button" value = " 1 " name = "1" onclick = "Call Math('1')"></td>
<td><input type = "button" value = " 2 " name = "2" onclick = "Call Math('2')"></td>
<td><input type = "button" value = " 3 " name = "3" onclick = "Call Math('3')"></td>
<td><input type = "button" value = " - " name = "-" onclick = "Call Math('-')"></td> </tr>
<tr>
<td colspan="3"><input type = "button" value = " + " name = "+" onclick = "Call Math('+')"></td>
<td rowspan="2"><input height="40" type = "button" value = " = " name = "=" onclick = "Call equals"></td>
</tr>
<tr>
<td height="28" colspan="3"><input name="button" type = "button" onclick = "Call Clear" value = " Clear All "></td>
</tr>
</table>
<br>
<br>
</center>
</form>
</body>
</html>
This aint VB Script brother. Its HTML
ReplyDelete@Anom: Look at this section:
ReplyDelete<script language = "VBscript">
...
</script>
The code written in above section is VBSCRIPT code. And other than that are html. I have written all code, so that a developer can create simple calculator (with all elements and buttons). I hope you understand it.
is not working dude
ReplyDeleteit will work,, vbscript runs only on internet explorer and not on any other new browsers like mozilla firefox, chrome etc.. try running it using IE..
ReplyDeletewin 10 IE is nt working dude
Deleteit is nt use.
ReplyDeleteI have updated a post above with little information regarding VBScript not running in browsers other than IE. Thanks.
Deleteabbey jab kuch ata nhn toh kyun blog banatey ho!
ReplyDeleteTujhe sab kuch ata hai to tu post karna tere blog mein, mere blog mein kyo tang atkateho bhai. By the way I wrote it years ago when I was in college. Today I am iPhone app and game developer by profession. No hard feelings. Ignore my post if it doesn't help you.
Deletenice one. works on ie but you forgot the zero ! mozilla-chrome no, I don't have others. any trick to make it work on those too ?
ReplyDeleteBro can you please explain how does it work specially function math(val) section.
ReplyDeleteIt is rather very good, nevertheless glance at the data with this handle. ounces in a pound
ReplyDeleteIt will work if you save it as "name.hta"
ReplyDeleteHELLO
ReplyDeleteMY
IM A INDUMINA