<!-- This script has been in the http://www.javascripts.com Javascript Public Library! -->
<!-- Note that though this material may have been in a public depository, certain author copyright restrictions may apply. -->
<html>

<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
<title>Applications</title>
</head>

<body bgcolor="#FFFFFF" link="#FF0000" vlink="#FF0000"
alink="#FF0000">
<p>Developed by <a href="http://www.synapseindia.com" target="_blank">Synapse Technologies.</a><p>
Also visit our tutorials website at <a href="http://www.gigastrata.com" target="_blank">Gigastrata</a>
<script language="VBScript">
<!--
' Module-level variables
Dim Accum ' Previous number (operand) awaiting operation
Dim FlagNewNum ' Flag to indicate a new number (operand) is being entered
Dim PendingOp ' Pending operation waiting for completion of second operand

Sub NumPressed(Byval Num)
If FlagNewNum Then
Document.Keypad.Readout.Value = Num
FlagNewNum = False
Else
If Document.Keypad.Readout.Value = "0" Then
Document.Keypad.Readout.Value = CStr(Num)
Else
Document.Keypad.ReadOut.Value= Document.Keypad.ReadOut.Value & CStr(Num)
End If
End If
End Sub

Sub Decimal_onClick()
Dim curReadout
curReadOut = Document.Keypad.ReadOut.Value
If FlagNewNum Then
curReadOut = "0."
FlagNewNum = False
Else
If InStr(curReadOut, ".") = 0 Then
curReadOut = curReadOut & "."
End If
End If
Document.Keypad.ReadOut.Value = curReadOut
End Sub

Sub Plus_onClick()
Operation "+"
End Sub

Sub Minus_onClick()
Operation "-"
End Sub

Sub Multiply_onClick()
Operation "*"
End Sub

Sub Divide_OnClick()
Operation "/"
End Sub

Sub Operation(Byval Op)
Dim Readout
ReadOut = Document.Keypad.ReadOut.Value
If FlagNewNum and PendingOp <> "=" Then
' User is hitting op keys repeatedly, so don't do anything
Else
FlagNewNum = True
Select Case PendingOp
Case "+"
Accum = CDbl(Accum) + CDbl(ReadOut)
Case "-"
Accum = CDbl(Accum) - CDbl(ReadOut)
Case "/"
Accum = CDbl(Accum) / CDbl(ReadOut)
Case "*"
Accum = CDbl(Accum) * CDbl(ReadOut)
Case Else
Accum = ReadOut
End Select
Document.Keypad.ReadOut.Value = Accum
PendingOp = Op
End If
End Sub

Sub ClearEntry_onClick()
' Remove current number and reset state
Document.Keypad.ReadOut.Value = "0"
FlagNewNum = True
End Sub

Sub Clear_onClick()
' Clear accumulator and pending operation, and clear display
Accum = 0
PendingOp = ""
ClearEntry_onClick
End Sub

Sub Neg_onClick()
Document.Keypad.ReadOut.Value = CDbl(Document.Keypad.ReadOut.Value) * -1
End Sub

Sub Percent_onClick()
Document.Keypad.ReadOut.Value = (CDbl(Document.Keypad.ReadOut.Value) / 100) * Accum
End Sub

Sub Equals_OnClick()
Operation "="
End Sub
-->
</script>

<form name="Keypad">
<table border="0">
<tr>
<td><table border="2" cellspacing="5" width="50"
height="60">
<tr>
<td align="middle" colspan="3"><b><input
type="text" size="24" name="ReadOut"
value="0" width="100%"></b></td>
<td><b></b>&nbsp;</td>
<td><b><input type="button" name="Clear"
value=" C "></b></td>
<td><b><input type="button" name="ClearEntry"
value=" CE "></b></td>
</tr>
<tr>
<td><b><input type="button" name="Seven"
value=" 7 " onclick="NumPressed(7)"></b></td>
<td><b><input type="button" name="Eight"
value=" 8 " onclick="NumPressed(8)"></b></td>
<td><b><input type="button" name="Nine"
value=" 9 " onclick="NumPressed(9)"></b></td>
<td><b></b>&nbsp;</td>
<td><b><input type="button" name="Neg"
value=" +/- "></b></td>
<td><b><input type="button" name="Percent"
value=" % "></b></td>
</tr>
<tr>
<td><b><input type="button" name="Four"
value=" 4 " onclick="NumPressed(4)"></b></td>
<td><b><input type="button" name="Five"
value=" 5 " onclick="NumPressed(5)"></b></td>
<td><b><input type="button" name="Six"
value=" 6 " onclick="NumPressed(6)"></b></td>
<td><b></b>&nbsp;</td>
<td align="middle"><b><input type="button"
name="Plus" value=" + "></b></td>
<td align="middle"><b><input type="button"
name="Minus" value=" - "></b></td>
</tr>
<tr>
<td><b><input type="button" name="One"
value=" 1 " onclick="NumPressed(1)"></b></td>
<td><b><input type="button" name="Two"
value=" 2 " onclick="NumPressed(2)"></b></td>
<td><b><input type="button" name="Three"
value=" 3 " onclick="NumPressed(3)"></b></td>
<td><b></b>&nbsp;</td>
<td align="middle"><b><input type="button"
name="Multiply" value=" * "></b></td>
<td align="middle"><b><input type="button"
name="Divide" value=" / "></b></td>
</tr>
<tr>
<td><b><input type="button" name="Zero"
value=" 0 " onclick="NumPressed(0)"></b></td>
<td><b><input type="button" name="Decimal"
value=" . "></b></td>
<td colspan="3"><b></b>&nbsp;</td>
<td><b><input type="button" name="Equals"
value=" = "></b></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
 

<!-- Simba says Roar. -->