Calculator Calculator System Form1 Readout Number System Number System Number System Cancel System CancelEntry System Number System Number System Number System Operator System Operator System Number System Number System Number System Operator System Operator System Number System Decimal System Operator System Percent System DecimalFlagw NumOps- LastInput OpFlag FALSEH @ Form_Load Percent_Click Readout Caption Cancel_Click Decimal_Click, CancelEntry_Click Number_Click Index Number Operator_Click Operator Readout_Clickc Readout_Change5 Number_KeyPress KeyAscii Number_KeyDownS KeyCode Shift command1 getfocus sendmessage BM_SETSTATE LastKey lastindexA ProcessKeyDown lasttype GoodKeys Number_KeyUp4 ProcessKeyUp KeyState KEY_NUMPAD0 KEY_NUMPAD9Y Operator_KeyDown Operator_KeyUp{ KEY_NUMPAD KEY_RETURN Percent_KeyDown Decimal_KeyDown Cancel_KeyDown CancelEntry_KeyDownD Cancel_KeyUp CancelEntry_KeyUp Decimal_KeyUp Percent_KeyUp KEY_ADD KEY_SUBTRACT KEY_MULTIPLY KEY_DIVIDE KEY_DECIMAL Decimal Percent Clear_Click Cancel CancelEntry Copyright (C) 1991 Microsoft Corporation- You have a royalty-free right to use, modify, reproduce and distribute- the Sample Application Files (and/or any modified version) in any way you find useful, provided that you agree that Microsoft has no warranty, obligations or liability for any Sample Application Files.s Modifications & Enhancements by Marcus Smaby - these modificationss & enhancements released to the public domainn Previously input operand. Second operand. Decimal point present yet? Number of operands. Indicate type of last keypress. Indicate pending operation. Handle to Control Was this a key we can process Remember state of Key to prevent repeat scan code of last key Form_Load Initialization routine for the form.t Set all variables to initial values.t Percent_Click Click event procedure for percent key (%). Compute and display a percentage of the first operand.- Cancel_Click Click event procedure for C (cancel) key. Reset the display and initializes variables.t Decimal_Click Click event procedure for decimal point (.) key.e If last keypress was an operator, initializek readout to "0." Otherwise, append a decimal point to the display. CancelEntry_Click Click event procedure for CE (cancel entry) key.e Number_Click Click event procedure for number keys (0-9).k Appends new number to the number in the display.e Operator_Click Click event procedure for operator keys (+, -, x, /, =). If the immediately preceeding keypress was part of a number, increment NumOps. If one operand is present, set Op1. If two are present, set Op1 equal to the result of the operation on Op1 and the currentt input string, and display the result. Can't divide by zero Calculator Number_KeyDown ProcessKeyDown Key Table + = 43, - = 45, / = 47 * = 42 % = 37, = = 61, c = 99,67, . = 46 Avoid Auto Repeat classify keystroke & act Debug.Print lastkey 0 - 9 p for percent C for Cancels <- or del for CancelEntry Get the Handle Set control as pressed0 Number_KeyUp ProcessKeyUp set control as unpressed Set Focus to Equals Key Operator_KeyDown Operator_KeyUp Percent_KeyDown Decimal_KeyDown Cancel_KeyDown CancelEntry_KeyDown Cancel_KeyUp CancelEntry_KeyUp Decimal_KeyUp Percent_KeyUp