2023-06-15 21:58:12 +00:00
|
|
|
': ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
|
|
|
|
': ||C |||A |||L |||C |||U |||L |||A |||T |||O |||R ||
|
|
|
|
': ||__|||__|||__|||__|||__|||__|||__|||__|||__|||__||
|
|
|
|
': |/__\|/__\|/__\|/__\|/__\|/__\|/__\|/__\|/__\|/__\|
|
|
|
|
':
|
|
|
|
': QB64 Calculator V1.0
|
|
|
|
': Terry Ritchie - 08/29/18
|
|
|
|
':
|
|
|
|
': Built as a clone of the Windows 7 standard calculator
|
|
|
|
': An exersize in getting to know the InForm library
|
|
|
|
':
|
|
|
|
': This program uses
|
|
|
|
': InForm - GUI library for QB64 - Beta version 7
|
|
|
|
': Fellippe Heitor, 2016-2018 - fellippe@qb64.org - @fellippeheitor
|
|
|
|
': https://github.com/FellippeHeitor/InForm
|
|
|
|
'----------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
OPTION _EXPLICIT
|
2023-06-15 21:58:12 +00:00
|
|
|
|
|
|
|
': Program constants: -------------------------------------------------------------------------------------------------
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CONST EQUATE = 0
|
|
|
|
CONST ADDITION = 1
|
|
|
|
CONST SUBTRACTION = 2
|
|
|
|
CONST MULTIPLICATION = 3
|
|
|
|
CONST DIVISION = 4
|
2023-06-15 21:58:12 +00:00
|
|
|
|
|
|
|
': Controls' IDs: -----------------------------------------------------------------------------------------------------
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
DIM SHARED Calculator AS LONG
|
|
|
|
DIM SHARED frmResults AS LONG
|
|
|
|
DIM SHARED mnuEdit AS LONG
|
|
|
|
DIM SHARED mnuHelp AS LONG
|
|
|
|
DIM SHARED butMC AS LONG
|
|
|
|
DIM SHARED butMR AS LONG
|
|
|
|
DIM SHARED butMS AS LONG
|
|
|
|
DIM SHARED butMplus AS LONG
|
|
|
|
DIM SHARED butMminus AS LONG
|
|
|
|
DIM SHARED butBS AS LONG
|
|
|
|
DIM SHARED butCE AS LONG
|
|
|
|
DIM SHARED butC AS LONG
|
|
|
|
DIM SHARED butSign AS LONG
|
|
|
|
DIM SHARED butSQR AS LONG
|
|
|
|
DIM SHARED but7 AS LONG
|
|
|
|
DIM SHARED but8 AS LONG
|
|
|
|
DIM SHARED but9 AS LONG
|
|
|
|
DIM SHARED butDivide AS LONG
|
|
|
|
DIM SHARED butPercent AS LONG
|
|
|
|
DIM SHARED but4 AS LONG
|
|
|
|
DIM SHARED but5 AS LONG
|
|
|
|
DIM SHARED but6 AS LONG
|
|
|
|
DIM SHARED butMultiply AS LONG
|
|
|
|
DIM SHARED butReciprocate AS LONG
|
|
|
|
DIM SHARED but1 AS LONG
|
|
|
|
DIM SHARED but2 AS LONG
|
|
|
|
DIM SHARED but3 AS LONG
|
|
|
|
DIM SHARED butSubtract AS LONG
|
|
|
|
DIM SHARED but0 AS LONG
|
|
|
|
DIM SHARED butPoint AS LONG
|
|
|
|
DIM SHARED butAdd AS LONG
|
|
|
|
DIM SHARED butEqual AS LONG
|
|
|
|
DIM SHARED mnuCopy AS LONG
|
|
|
|
DIM SHARED mnuPaste AS LONG
|
|
|
|
DIM SHARED mnuAbout AS LONG
|
|
|
|
DIM SHARED lblAnswer AS LONG
|
|
|
|
DIM SHARED lblMemory AS LONG
|
|
|
|
DIM SHARED lblHistory AS LONG
|
2023-06-15 21:58:12 +00:00
|
|
|
|
|
|
|
': Program variables: -------------------------------------------------------------------------------------------------
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
DIM SHARED operand$ ' current operand
|
|
|
|
DIM SHARED history$ ' calculation history
|
|
|
|
DIM SHARED operand1 AS DOUBLE ' first operand enetered
|
|
|
|
DIM SHARED operand2 AS DOUBLE ' second operand entered
|
|
|
|
DIM SHARED operator AS INTEGER ' current operator selected
|
|
|
|
DIM SHARED operator$(4)
|
|
|
|
DIM SHARED previousoperator AS INTEGER ' previous operator saved
|
|
|
|
DIM SHARED resetoperand AS INTEGER ' True when operand entry needs reset
|
|
|
|
DIM SHARED memory AS DOUBLE ' value stored in memory
|
|
|
|
DIM SHARED nohistory AS INTEGER
|
2023-06-15 21:58:12 +00:00
|
|
|
|
|
|
|
': External modules: --------------------------------------------------------------------------------------------------
|
2023-06-24 02:38:56 +00:00
|
|
|
'$INCLUDE:'../../InForm/InForm.bi'
|
2023-06-15 21:58:12 +00:00
|
|
|
'$INCLUDE:'Calculator.frm'
|
|
|
|
|
|
|
|
': Program procedures: ------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
'----------------------------------------------------------------------------------------------------------------------
|
2023-06-24 02:38:56 +00:00
|
|
|
SUB ALERT () ' ALERT()
|
2023-06-15 21:58:12 +00:00
|
|
|
'------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
DIM i AS LONG
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
PLAY "MBQ0" ' play in the background and disable volume ramping
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
FOR i = 800 TO 2000 STEP 100
|
|
|
|
SOUND i, .2
|
|
|
|
NEXT
|
|
|
|
FOR i = 2000 TO 50 STEP -100
|
|
|
|
SOUND i, .2
|
|
|
|
NEXT
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
END SUB
|
2023-06-15 21:58:12 +00:00
|
|
|
|
|
|
|
'----------------------------------------------------------------------------------------------------------------------
|
2023-06-24 02:38:56 +00:00
|
|
|
FUNCTION CLEAN$ (n AS DOUBLE) ' CLEAN$()
|
2023-06-15 21:58:12 +00:00
|
|
|
'------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
' Return number (n) as a string with no leading/trailing spaces
|
|
|
|
' Add leading zero if necessary
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
DIM c$ ' n converted to a clean string
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
c$ = LTRIM$(RTRIM$(STR$(n))) ' create clean string
|
|
|
|
IF ASC(c$, 1) = 46 THEN ' first character a decimal point?
|
2023-06-15 21:58:12 +00:00
|
|
|
c$ = "0" + c$ ' yes, add leading zero
|
2023-06-24 02:38:56 +00:00
|
|
|
ELSEIF ASC(c$, 1) = 45 AND ASC(c$, 2) = 46 THEN ' no, minus sign then decimal point?
|
|
|
|
c$ = "-0" + RIGHT$(c$, LEN(c$) - 1) ' yes, add leading zero
|
|
|
|
END IF
|
2023-06-15 21:58:12 +00:00
|
|
|
CLEAN$ = c$ ' return cleaned string
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
END FUNCTION
|
2023-06-15 21:58:12 +00:00
|
|
|
|
|
|
|
'----------------------------------------------------------------------------------------------------------------------
|
2023-06-24 02:38:56 +00:00
|
|
|
SUB UPDATEOPERAND (n$) ' UPDATEOPERAND()
|
2023-06-15 21:58:12 +00:00
|
|
|
'------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
' Add user entries to operand
|
|
|
|
' Keep operand to a max length of 16 numbers (not including decimal point)
|
|
|
|
' Reset user operand input as needed
|
|
|
|
' Keep leading zero for decimal values between one and negative one
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
DIM olen AS INTEGER ' operand length
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
IF resetoperand THEN ' new operand input?
|
2023-06-15 21:58:12 +00:00
|
|
|
operand$ = "" ' yes, reset operand
|
|
|
|
resetoperand = False ' reset trigger
|
2023-06-24 02:38:56 +00:00
|
|
|
END IF
|
|
|
|
IF n$ = "." THEN ' adding decimal point?
|
|
|
|
IF INSTR(operand$, ".") = 0 THEN ' yes, already a decimal point?
|
|
|
|
IF operand$ = "" THEN ' no, has operand been reset?
|
2023-06-15 21:58:12 +00:00
|
|
|
n$ = "0." ' yes, add leading zero
|
2023-06-24 02:38:56 +00:00
|
|
|
END IF
|
|
|
|
ELSE ' yes, decimal point exists
|
2023-06-15 21:58:12 +00:00
|
|
|
n$ = "" ' ignore user request for decimal point
|
2023-06-24 02:38:56 +00:00
|
|
|
END IF
|
|
|
|
END IF
|
2023-06-15 21:58:12 +00:00
|
|
|
operand$ = operand$ + n$ ' update operand with user entry
|
2023-06-24 02:38:56 +00:00
|
|
|
olen = LEN(operand$) ' get length of operand
|
|
|
|
IF INSTR(operand$, ".") > 0 THEN olen = olen - 1 ' don't count decimal point if preset
|
|
|
|
IF olen > 16 THEN operand$ = LEFT$(operand$, LEN(operand$) - 1) ' keep operand within 16 number limit
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
END SUB
|
2023-06-15 21:58:12 +00:00
|
|
|
|
|
|
|
'----------------------------------------------------------------------------------------------------------------------
|
2023-06-24 02:38:56 +00:00
|
|
|
SUB CALCULATE () ' CALCULATE()
|
2023-06-15 21:58:12 +00:00
|
|
|
'------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
' Calculate operand values based on operator previously used
|
|
|
|
' Store result back into current operand
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
SELECT CASE previousoperator ' which operator to use?
|
|
|
|
CASE ADDITION ' add the operands
|
2023-06-15 21:58:12 +00:00
|
|
|
operand$ = CLEAN$(operand1 + operand2) ' perform clculation
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE SUBTRACTION ' subtract the operands
|
2023-06-15 21:58:12 +00:00
|
|
|
operand$ = CLEAN$(operand1 - operand2) ' perform calculation
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE MULTIPLICATION ' multiply the operands
|
2023-06-15 21:58:12 +00:00
|
|
|
operand$ = CLEAN$(operand1 * operand2) ' perform calculation
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE DIVISION ' divide the operands
|
|
|
|
IF operand2 = 0 THEN ' dividing by zero?
|
2023-06-15 21:58:12 +00:00
|
|
|
ALERT ' get user's attention
|
|
|
|
operand$ = "Can't divide by zero!" ' yes, not in this universe!
|
2023-06-24 02:38:56 +00:00
|
|
|
ELSE ' no, physics is safe for now
|
2023-06-15 21:58:12 +00:00
|
|
|
operand$ = CLEAN$(operand1 / operand2) ' perform calculation
|
2023-06-24 02:38:56 +00:00
|
|
|
END IF
|
|
|
|
END SELECT
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
END SUB
|
2023-06-15 21:58:12 +00:00
|
|
|
|
|
|
|
'----------------------------------------------------------------------------------------------------------------------
|
2023-06-24 02:38:56 +00:00
|
|
|
SUB COMMITOPERAND () ' COMMITOPERAND()
|
2023-06-15 21:58:12 +00:00
|
|
|
'------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
' Get value of current operand
|
|
|
|
' Calculate operands if necessary
|
|
|
|
' Save current operand value
|
|
|
|
' Remember the operator that invoked this routine
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
operand2 = VAL(operand$) ' store value of current operand
|
|
|
|
IF previousoperator THEN ' previous operator selected?
|
2023-06-15 21:58:12 +00:00
|
|
|
CALCULATE ' yes, calculate
|
2023-06-24 02:38:56 +00:00
|
|
|
END IF
|
|
|
|
operand1 = VAL(operand$) ' move current total to previous value
|
2023-06-15 21:58:12 +00:00
|
|
|
previousoperator = operator ' move current operator to previous operator
|
|
|
|
resetoperand = True ' trigger an operand reset
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
END SUB
|
2023-06-15 21:58:12 +00:00
|
|
|
|
|
|
|
'----------------------------------------------------------------------------------------------------------------------
|
2023-06-24 02:38:56 +00:00
|
|
|
SUB SCANKEYBOARD () ' SCANKEYBOARD()
|
2023-06-15 21:58:12 +00:00
|
|
|
'------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
' Scan the keyboard for user keystrokes
|
|
|
|
' Invoke the appropriate button for the desired key
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
DIM k$ ' key pressed by user
|
|
|
|
DIM ctrl AS INTEGER
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
k$ = INKEY$ ' look for a key press
|
|
|
|
IF k$ <> "" THEN ' was a key pressed?
|
|
|
|
SELECT CASE k$ ' yes, which one?
|
|
|
|
CASE "0" ' zero key pressed
|
2023-06-15 21:58:12 +00:00
|
|
|
__UI_Click (but0) ' manually click the zero button
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE "1" ' etc..
|
2023-06-15 21:58:12 +00:00
|
|
|
__UI_Click (but1) ' etc..
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE "2"
|
2023-06-15 21:58:12 +00:00
|
|
|
__UI_Click (but2)
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE "3"
|
2023-06-15 21:58:12 +00:00
|
|
|
__UI_Click (but3)
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE "4"
|
2023-06-15 21:58:12 +00:00
|
|
|
__UI_Click (but4)
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE "5"
|
2023-06-15 21:58:12 +00:00
|
|
|
__UI_Click (but5)
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE "6"
|
2023-06-15 21:58:12 +00:00
|
|
|
__UI_Click (but6)
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE "7"
|
2023-06-15 21:58:12 +00:00
|
|
|
__UI_Click (but7)
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE "8"
|
2023-06-15 21:58:12 +00:00
|
|
|
__UI_Click (but8)
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE "9"
|
2023-06-15 21:58:12 +00:00
|
|
|
__UI_Click (but9)
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE "."
|
2023-06-15 21:58:12 +00:00
|
|
|
__UI_Click (butPoint)
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE "+"
|
2023-06-15 21:58:12 +00:00
|
|
|
__UI_Click (butAdd)
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE "-"
|
2023-06-15 21:58:12 +00:00
|
|
|
__UI_Click (butSubtract)
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE "*"
|
2023-06-15 21:58:12 +00:00
|
|
|
__UI_Click (butMultiply)
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE "/"
|
2023-06-15 21:58:12 +00:00
|
|
|
__UI_Click (butDivide)
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE "%"
|
2023-06-15 21:58:12 +00:00
|
|
|
__UI_Click (butPercent)
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE "=", CHR$(13) ' treat ENTER and = the same
|
2023-06-15 21:58:12 +00:00
|
|
|
__UI_Click (butEqual)
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE CHR$(8) ' backspace key pressed
|
2023-06-15 21:58:12 +00:00
|
|
|
__UI_Click (butBS)
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE "c", "C" ' CTRL-C copy
|
|
|
|
ctrl = _KEYDOWN(100305) OR _KEYDOWN(100306)
|
|
|
|
IF ctrl THEN BEEP
|
2023-06-15 21:58:12 +00:00
|
|
|
|
|
|
|
' Will need to investigate how to capture CTRL-C and CTRL-V
|
|
|
|
' Neither the code above or below works
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE "v", "V" ' CTRL-V paste
|
|
|
|
IF __UI_CtrlIsDown THEN ' is CTRL key presses?
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
BEEP
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
END IF
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
END SELECT
|
|
|
|
END IF
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
END SUB
|
2023-06-15 21:58:12 +00:00
|
|
|
|
|
|
|
'----------------------------------------------------------------------------------------------------------------------
|
2023-06-24 02:38:56 +00:00
|
|
|
SUB ADDHISTORY (h$) ' ADDHISTORY()
|
2023-06-15 21:58:12 +00:00
|
|
|
'------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
IF nohistory THEN
|
2023-06-15 21:58:12 +00:00
|
|
|
nohistory = False
|
2023-06-24 02:38:56 +00:00
|
|
|
ELSE
|
2023-06-15 21:58:12 +00:00
|
|
|
history$ = history$ + h$
|
2023-06-24 02:38:56 +00:00
|
|
|
END IF
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
END SUB
|
2023-06-15 21:58:12 +00:00
|
|
|
|
|
|
|
'----------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
': Event procedures: --------------------------------------------------------------------------------------------------
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
SUB __UI_BeforeInit
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
END SUB
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
SUB __UI_OnLoad
|
2023-06-15 21:58:12 +00:00
|
|
|
|
|
|
|
operator$(1) = " + " ' define operator strings
|
|
|
|
operator$(2) = " - "
|
|
|
|
operator$(3) = " * "
|
|
|
|
operator$(4) = " / "
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
END SUB
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
SUB __UI_BeforeUpdateDisplay
|
2023-06-15 21:58:12 +00:00
|
|
|
'This event occurs at approximately 30 frames per second.
|
|
|
|
'You can change the update frequency by calling SetFrameRate DesiredRate%
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
DIM answer$ ' current operand displayed
|
2023-06-15 21:58:12 +00:00
|
|
|
|
|
|
|
SCANKEYBOARD ' process keys pressed by user
|
|
|
|
|
|
|
|
Caption(lblHistory) = history$ + operator$(operator) ' update history display
|
|
|
|
|
|
|
|
answer$ = operand$ ' copy operand
|
2023-06-24 02:38:56 +00:00
|
|
|
IF answer$ = "" THEN answer$ = "0" ' set to zero if empty
|
2023-06-15 21:58:12 +00:00
|
|
|
|
|
|
|
Caption(lblAnswer) = answer$ ' display current operand
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
IF memory THEN ' does memory have value?
|
2023-06-15 21:58:12 +00:00
|
|
|
Caption(lblMemory) = "M" ' yes, apply screen indication
|
2023-06-24 02:38:56 +00:00
|
|
|
ELSE ' no
|
2023-06-15 21:58:12 +00:00
|
|
|
Caption(lblMemory) = "" ' remove screen indication
|
2023-06-24 02:38:56 +00:00
|
|
|
END IF
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
END SUB
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
SUB __UI_BeforeUnload
|
2023-06-15 21:58:12 +00:00
|
|
|
'If you set __UI_UnloadSignal = False here you can
|
|
|
|
'cancel the user's request to close.
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
END SUB
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
SUB __UI_Click (id AS LONG)
|
|
|
|
SELECT CASE id
|
|
|
|
CASE Calculator
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE frmResults
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE mnuEdit
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE mnuHelp
|
2023-06-15 21:58:12 +00:00
|
|
|
|
|
|
|
': memory buttons: ----------------------------------------------------------------------------------------
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMC ' memory clear clicked
|
2023-06-15 21:58:12 +00:00
|
|
|
memory = 0 ' reset memory value
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMR ' memory recall clicked
|
|
|
|
IF memory THEN ' memory available?
|
2023-06-15 21:58:12 +00:00
|
|
|
operand$ = CLEAN$(memory) ' Yes, make it the current operand
|
|
|
|
resetoperand = True ' trigger an operand reset
|
2023-06-24 02:38:56 +00:00
|
|
|
END IF
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMS ' memory store clicked
|
|
|
|
memory = VAL(operand$) ' overwrite memory with current operand
|
2023-06-15 21:58:12 +00:00
|
|
|
resetoperand = True ' trigger an operand reset
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMplus ' memory addition clicked
|
|
|
|
memory = memory + VAL(operand$) ' add current operand to memory
|
2023-06-15 21:58:12 +00:00
|
|
|
resetoperand = True ' trigger an operand reset
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMminus ' memory subtraction clicked
|
|
|
|
memory = memory - VAL(operand$) ' subtract current operand from memory
|
2023-06-15 21:58:12 +00:00
|
|
|
resetoperand = True ' trigger an operand reset
|
|
|
|
|
|
|
|
': clear buttons: -----------------------------------------------------------------------------------------
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butCE ' clear entry clicked
|
2023-06-15 21:58:12 +00:00
|
|
|
operand$ = "" ' reset current operand
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butC ' clear clicked
|
2023-06-15 21:58:12 +00:00
|
|
|
operand1 = 0 ' initialize all values
|
|
|
|
operand2 = 0
|
|
|
|
operator = 0
|
|
|
|
previousoperator = 0
|
|
|
|
operand$ = ""
|
|
|
|
history$ = ""
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butBS ' backspace clicked
|
|
|
|
IF LEN(operand$) THEN ' characters in operand?
|
|
|
|
operand$ = LEFT$(operand$, LEN(operand$) - 1) ' yes, remove right-most character
|
|
|
|
END IF
|
2023-06-15 21:58:12 +00:00
|
|
|
|
|
|
|
': calculation buttons: -----------------------------------------------------------------------------------
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butReciprocate ' reciprocate clicked
|
|
|
|
IF VAL(operand$) THEN ' dividing by zero?
|
2023-06-15 21:58:12 +00:00
|
|
|
|
|
|
|
ADDHISTORY (operator$(previousoperator) + "Reciproc(" + operand$ + ")")
|
|
|
|
nohistory = True ' skip operand history next time
|
|
|
|
operator = EQUATE
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
operand$ = CLEAN$(1 / VAL(operand$)) ' no, calculate reciprocate
|
|
|
|
ELSE ' yes, physics will collapse!
|
2023-06-15 21:58:12 +00:00
|
|
|
ALERT ' get user's attention
|
|
|
|
operand$ = "Can't divide by zero!" ' report error to user
|
2023-06-24 02:38:56 +00:00
|
|
|
END IF
|
2023-06-15 21:58:12 +00:00
|
|
|
resetoperand = True ' trigger an operand reset
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butSQR ' square root clicked
|
|
|
|
IF VAL(operand$) >= 0 THEN ' positive value?
|
2023-06-15 21:58:12 +00:00
|
|
|
|
|
|
|
ADDHISTORY (operator$(previousoperator) + "SQRT(" + operand$ + ")")
|
|
|
|
nohistory = True ' skip operand history next time
|
|
|
|
operator = EQUATE
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
operand$ = CLEAN$(SQR(VAL(operand$))) ' yes, calculate square root
|
|
|
|
ELSE ' no, value is negative
|
2023-06-15 21:58:12 +00:00
|
|
|
ALERT ' get user's attention
|
|
|
|
operand$ = "Invalid input!" ' nice try buddy
|
2023-06-24 02:38:56 +00:00
|
|
|
END IF
|
2023-06-15 21:58:12 +00:00
|
|
|
resetoperand = True ' trigger an operand reset
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butPercent ' percent clicked
|
|
|
|
operand$ = CLEAN$(operand1 * VAL(operand$) / 100) ' calculate percentage of previous operand
|
2023-06-15 21:58:12 +00:00
|
|
|
resetoperand = True
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butSign ' sign clicked
|
|
|
|
IF VAL(operand$) THEN ' value equal to zero?
|
|
|
|
operand$ = CLEAN$(-VAL(operand$)) ' no, reverse sign of operand
|
|
|
|
END IF
|
2023-06-15 21:58:12 +00:00
|
|
|
|
|
|
|
': number buttons: ----------------------------------------------------------------------------------------
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but0 ' zero clicked
|
|
|
|
IF VAL(operand$) OR INSTR(operand$, ".") THEN ' ok to add a zero?
|
2023-06-15 21:58:12 +00:00
|
|
|
UPDATEOPERAND ("0") ' yes, append zero
|
2023-06-24 02:38:56 +00:00
|
|
|
END IF
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but1 ' one clicked
|
2023-06-15 21:58:12 +00:00
|
|
|
UPDATEOPERAND ("1") ' append one
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but2 ' etc..
|
2023-06-15 21:58:12 +00:00
|
|
|
UPDATEOPERAND ("2") ' etc..
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but3
|
2023-06-15 21:58:12 +00:00
|
|
|
UPDATEOPERAND ("3")
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but4
|
2023-06-15 21:58:12 +00:00
|
|
|
UPDATEOPERAND ("4")
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but5
|
2023-06-15 21:58:12 +00:00
|
|
|
UPDATEOPERAND ("5")
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but6
|
2023-06-15 21:58:12 +00:00
|
|
|
UPDATEOPERAND ("6")
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but7
|
2023-06-15 21:58:12 +00:00
|
|
|
UPDATEOPERAND ("7")
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but8
|
2023-06-15 21:58:12 +00:00
|
|
|
UPDATEOPERAND ("8")
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but9
|
2023-06-15 21:58:12 +00:00
|
|
|
UPDATEOPERAND ("9")
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butPoint
|
2023-06-15 21:58:12 +00:00
|
|
|
UPDATEOPERAND (".")
|
|
|
|
|
|
|
|
': operator buttons: --------------------------------------------------------------------------------------
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butDivide ' divide clicked
|
2023-06-15 21:58:12 +00:00
|
|
|
|
|
|
|
ADDHISTORY (operator$(previousoperator) + operand$)
|
|
|
|
|
|
|
|
operator = DIVISION ' remember operator selected
|
|
|
|
COMMITOPERAND ' save operand
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMultiply ' multiply clicked
|
2023-06-15 21:58:12 +00:00
|
|
|
|
|
|
|
ADDHISTORY (operator$(previousoperator) + operand$)
|
|
|
|
|
|
|
|
operator = MULTIPLICATION ' remember operator selected
|
|
|
|
COMMITOPERAND ' save operand
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butSubtract ' subtract clicked
|
2023-06-15 21:58:12 +00:00
|
|
|
|
|
|
|
ADDHISTORY (operator$(previousoperator) + operand$)
|
|
|
|
|
|
|
|
operator = SUBTRACTION ' remember operator selected
|
|
|
|
COMMITOPERAND ' save operand
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butAdd ' addition clicked
|
2023-06-15 21:58:12 +00:00
|
|
|
|
|
|
|
ADDHISTORY (operator$(previousoperator) + operand$)
|
|
|
|
|
|
|
|
operator = ADDITION ' remember operator selected
|
|
|
|
COMMITOPERAND ' save operand
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butEqual ' equal clicked
|
2023-06-15 21:58:12 +00:00
|
|
|
|
|
|
|
history$ = ""
|
|
|
|
operator = EQUATE ' remember operator selected
|
|
|
|
COMMITOPERAND ' save operand
|
|
|
|
previousoperator = 0
|
|
|
|
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE mnuCopy
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE mnuPaste
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE mnuAbout
|
|
|
|
_DELAY 0.2: _MESSAGEBOX "Calculator", "InForm Calculator 1.0", "info"
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE lblAnswer
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE lblMemory
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE lblHistory
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
END SELECT
|
|
|
|
END SUB
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
SUB __UI_MouseEnter (id AS LONG)
|
|
|
|
SELECT CASE id
|
|
|
|
CASE Calculator
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE frmResults
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE mnuEdit
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE mnuHelp
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMC
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMR
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMS
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMplus
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMminus
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butBS
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butCE
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butC
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butSign
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butSQR
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but7
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but8
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but9
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butDivide
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butPercent
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but4
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but5
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but6
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMultiply
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butReciprocate
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but1
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but2
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but3
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butSubtract
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but0
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butPoint
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butAdd
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butEqual
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE mnuCopy
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE mnuPaste
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE mnuAbout
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE lblAnswer
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE lblMemory
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE lblHistory
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
END SELECT
|
|
|
|
END SUB
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
SUB __UI_MouseLeave (id AS LONG)
|
|
|
|
SELECT CASE id
|
|
|
|
CASE Calculator
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE frmResults
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE mnuEdit
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE mnuHelp
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMC
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMR
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMS
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMplus
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMminus
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butBS
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butCE
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butC
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butSign
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butSQR
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but7
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but8
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but9
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butDivide
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butPercent
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but4
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but5
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but6
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMultiply
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butReciprocate
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but1
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but2
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but3
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butSubtract
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but0
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butPoint
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butAdd
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butEqual
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE mnuCopy
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE mnuPaste
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE mnuAbout
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE lblAnswer
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE lblMemory
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE lblHistory
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
END SELECT
|
|
|
|
END SUB
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
SUB __UI_FocusIn (id AS LONG)
|
|
|
|
SELECT CASE id
|
|
|
|
CASE butMC
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMR
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMS
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMplus
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMminus
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butBS
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butCE
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butC
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butSign
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butSQR
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but7
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but8
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but9
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butDivide
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butPercent
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but4
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but5
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but6
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMultiply
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butReciprocate
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but1
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but2
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but3
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butSubtract
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but0
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butPoint
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butAdd
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butEqual
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
END SELECT
|
|
|
|
END SUB
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
SUB __UI_FocusOut (id AS LONG)
|
2023-06-15 21:58:12 +00:00
|
|
|
'This event occurs right before a control loses focus.
|
|
|
|
'To prevent a control from losing focus, set __UI_KeepFocus = True below.
|
2023-06-24 02:38:56 +00:00
|
|
|
SELECT CASE id
|
|
|
|
CASE butMC
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMR
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMS
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMplus
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMminus
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butBS
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butCE
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butC
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butSign
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butSQR
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but7
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but8
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but9
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butDivide
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butPercent
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but4
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but5
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but6
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMultiply
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butReciprocate
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but1
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but2
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but3
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butSubtract
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but0
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butPoint
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butAdd
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butEqual
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
END SELECT
|
|
|
|
END SUB
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
SUB __UI_MouseDown (id AS LONG)
|
|
|
|
SELECT CASE id
|
|
|
|
CASE Calculator
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE frmResults
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE mnuEdit
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE mnuHelp
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMC
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMR
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMS
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMplus
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMminus
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butBS
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butCE
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butC
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butSign
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butSQR
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but7
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but8
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but9
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butDivide
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butPercent
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but4
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but5
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but6
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMultiply
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butReciprocate
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but1
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but2
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but3
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butSubtract
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but0
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butPoint
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butAdd
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butEqual
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE mnuCopy
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE mnuPaste
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE mnuAbout
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE lblAnswer
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE lblMemory
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE lblHistory
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
END SELECT
|
|
|
|
END SUB
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
SUB __UI_MouseUp (id AS LONG)
|
|
|
|
SELECT CASE id
|
|
|
|
CASE Calculator
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE frmResults
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE mnuEdit
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE mnuHelp
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMC
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMR
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMS
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMplus
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMminus
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butBS
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butCE
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butC
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butSign
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butSQR
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but7
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but8
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but9
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butDivide
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butPercent
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but4
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but5
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but6
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMultiply
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butReciprocate
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but1
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but2
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but3
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butSubtract
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but0
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butPoint
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butAdd
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butEqual
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE mnuCopy
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE mnuPaste
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE mnuAbout
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE lblAnswer
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE lblMemory
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE lblHistory
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
END SELECT
|
|
|
|
END SUB
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
SUB __UI_KeyPress (id AS LONG)
|
2023-06-15 21:58:12 +00:00
|
|
|
'When this event is fired, __UI_KeyHit will contain the code of the key hit.
|
|
|
|
'You can change it and even cancel it by making it = 0
|
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
SELECT CASE id
|
|
|
|
CASE butMC
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMR
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMS
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMplus
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMminus
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butBS
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butCE
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butC
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butSign
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butSQR
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but7
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but8
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but9
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butDivide
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butPercent
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but4
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but5
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but6
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butMultiply
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butReciprocate
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but1
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but2
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but3
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butSubtract
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE but0
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butPoint
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butAdd
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
CASE butEqual
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
END SELECT
|
|
|
|
END SUB
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
SUB __UI_TextChanged (id AS LONG)
|
|
|
|
SELECT CASE id
|
|
|
|
END SELECT
|
|
|
|
END SUB
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
SUB __UI_ValueChanged (id AS LONG)
|
|
|
|
SELECT CASE id
|
|
|
|
END SELECT
|
|
|
|
END SUB
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
SUB __UI_FormResized
|
|
|
|
END SUB
|
2023-06-15 21:58:12 +00:00
|
|
|
|
2023-06-24 02:38:56 +00:00
|
|
|
'$INCLUDE:'../../InForm/InForm.ui'
|
|
|
|
'$INCLUDE:'../../InForm/xp.uitheme'
|