VERSION 5.00 Begin VB.Form Calculator Caption = "Calculator" ClientHeight = 4335 ClientLeft = 3255 ClientTop = 2145 ClientWidth = 3510 LinkTopic = "Form2" PaletteMode = 1 'UseZOrder ScaleHeight = 4335 ScaleWidth = 3510 Begin VB.CommandButton cmdPower Caption = "ON/OFF" Height = 560 Left = 2160 TabIndex = 18 Top = 960 Width = 1095 End Begin VB.CommandButton cmdMSubtract Caption = "M-" Height = 495 Left = 2760 TabIndex = 17 Top = 2280 Width = 495 End Begin VB.CommandButton cmdMAdd Caption = "M+" Height = 495 Left = 2760 TabIndex = 16 Top = 2880 Width = 495 End Begin VB.CommandButton cmdMRecall Caption = "M" Height = 495 Left = 2760 TabIndex = 15 Top = 1680 Width = 495 End Begin VB.CommandButton cmdTotal Caption = "=" Height = 495 Left = 2160 TabIndex = 14 Top = 3480 Width = 1095 End Begin VB.CommandButton cmdAdd Caption = "+" Height = 495 Left = 2160 TabIndex = 13 Top = 2880 Width = 495 End Begin VB.CommandButton cmdSubtract Caption = "-" Height = 495 Left = 2160 TabIndex = 12 Top = 2280 Width = 495 End Begin VB.CommandButton cmdClear Caption = "C" Height = 495 Left = 2160 TabIndex = 11 Top = 1680 Width = 495 End Begin VB.CommandButton cmdNumber Caption = "0" Height = 495 Index = 0 Left = 840 TabIndex = 10 Top = 3480 Width = 495 End Begin VB.CommandButton cmdNumber Caption = "9" Height = 495 Index = 9 Left = 1440 TabIndex = 9 Top = 1680 Width = 495 End Begin VB.CommandButton cmdNumber Caption = "8" Height = 495 Index = 8 Left = 840 TabIndex = 8 Top = 1680 Width = 495 End Begin VB.CommandButton cmdNumber Caption = "7" Height = 495 Index = 7 Left = 240 TabIndex = 7 Top = 1680 Width = 495 End Begin VB.CommandButton cmdNumber Caption = "6" Height = 495 Index = 6 Left = 1440 TabIndex = 6 Top = 2280 Width = 495 End Begin VB.CommandButton cmdNumber Caption = "5" Height = 495 Index = 5 Left = 840 TabIndex = 5 Top = 2280 Width = 495 End Begin VB.CommandButton cmdNumber Caption = "4" Height = 495 Index = 4 Left = 240 TabIndex = 4 Top = 2280 Width = 495 End Begin VB.CommandButton cmdNumber Caption = "3" Height = 495 Index = 3 Left = 1440 TabIndex = 3 Top = 2880 Width = 495 End Begin VB.CommandButton cmdNumber Caption = "2" Height = 495 Index = 2 Left = 840 TabIndex = 2 Top = 2880 Width = 495 End Begin VB.CommandButton cmdNumber Caption = "1" Height = 495 Index = 1 Left = 240 TabIndex = 1 Top = 2880 Width = 495 End Begin VB.TextBox txtDisplay Alignment = 1 'Right Justify BeginProperty Font Name = "MS Sans Serif" Size = 16.5 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H00800000& Height = 555 Left = 240 TabIndex = 0 Top = 960 Width = 1695 End Begin VB.Label Label1 Alignment = 2 'Center Caption = "CALCULATOR APPLET" BeginProperty Font Name = "MS Sans Serif" Size = 12 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Left = 240 TabIndex = 19 Top = 360 Width = 3015 End End Attribute VB_Name = "Calculator" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Const NUMBER As Integer = -1 Const CLEAR As Integer = 0 Const ADD As Integer = 1 Const SUBTRACT As Integer = 2 Const TOTAL As Integer = 3 Const MEMORY As Integer = 4 Const OFFMSG As String = "Power Off" Dim nValue As Integer Dim nTotal As Integer Dim nMemory As Integer Dim nAction As Integer Dim nPrevious As Integer Dim bOn As Boolean Sub Calculate() nValue = Val(txtDisplay.Text) If (nAction = ADD) Then nTotal = nTotal + nValue ElseIf (nAction = SUBTRACT) Then nTotal = nTotal - nValue Else nTotal = nValue End If txtDisplay.Text = Str(nTotal) End Sub Sub KeyPressed(szKey As String) If bOn Then If (nPrevious = NUMBER) Then txtDisplay.Text = txtDisplay.Text + szKey Else txtDisplay.Text = szKey End If nPrevious = NUMBER End If End Sub Private Sub cmdAdd_Click() If bOn Then Calculate nPrevious = ADD nAction = ADD End If End Sub Private Sub cmdClear_Click() If bOn Then nValue = 0 nTotal = 0 nMemory = 0 txtDisplay.Text = Str(nTotal) nPrevious = CLEAR nAction = CLEAR End If End Sub Private Sub cmdMAdd_Click() If bOn Then nMemory = nMemory + Val(txtDisplay.Text) nPrevious = MEMORY End If End Sub Private Sub cmdMRecall_Click() If bOn Then txtDisplay.Text = Str(nMemory) nPrevious = MEMORY End If End Sub Private Sub cmdMSubtract_Click() If bOn Then nMemory = nMemory - Val(txtDisplay.Text) nPrevious = MEMORY End If End Sub Private Sub cmdNumber_Click(Index As Integer) KeyPressed CStr(Index) End Sub Private Sub cmdPower_Click() If bOn Then txtDisplay.Text = OFFMSG bOn = False Else txtDisplay.Text = " 0" bOn = True End If nMemory = 0 nTotal = 0 nValue = 0 End Sub Private Sub cmdSubtract_Click() If bOn Then Calculate nPrevious = SUBTRACT nAction = SUBTRACT End If End Sub Private Sub cmdTotal_Click() If bOn Then Calculate nPrevious = TOTAL nAction = TOTAL End If End Sub Private Sub Form_Load() txtDisplay.Locked = True txtDisplay.Text = "Power Off" End Sub