home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form HexCalcFrm
- BackColor = &H00C0C0C0&
- BorderStyle = 3 'Fixed Double
- Caption = "HexCalc"
- ClientHeight = 4740
- ClientLeft = 3060
- ClientTop = 2505
- ClientWidth = 3945
- Height = 5430
- Icon = HEXCALC.FRX:0000
- Left = 3000
- LinkTopic = "Form1"
- ScaleHeight = 540
- ScaleWidth = 540
- Top = 1875
- Width = 4065
- Begin CommandButton ExponButton
- Caption = "^"
- Height = 375
- Left = 3060
- TabIndex = 37
- Tag = "Exponentiation"
- Top = 2940
- Width = 615
- End
- Begin CommandButton DivButton
- Caption = "/"
- Height = 375
- Left = 3060
- TabIndex = 36
- Tag = "Divide current value"
- Top = 1680
- Width = 615
- End
- Begin CommandButton MultButton
- Caption = "X"
- Height = 375
- Left = 2400
- TabIndex = 35
- Tag = "Multiply current value"
- Top = 1680
- Width = 615
- End
- Begin CommandButton ComplementButton
- Caption = "Not"
- Height = 375
- Left = 2400
- TabIndex = 34
- Tag = "Perform Boolean complement"
- Top = 2940
- Width = 615
- End
- Begin CommandButton ORButton
- Caption = "OR"
- Height = 375
- Left = 3060
- TabIndex = 33
- Tag = "Perform Boolean OR operation"
- Top = 2520
- Width = 615
- End
- Begin CommandButton ANDButton
- Caption = "And"
- Height = 375
- Left = 2400
- TabIndex = 32
- Tag = "Perform Boolean AND operation"
- Top = 2520
- Width = 615
- End
- Begin CommandButton Erase
- Caption = "<-"
- Height = 315
- Left = 2940
- TabIndex = 31
- Tag = "Erase last character entered"
- Top = 900
- Width = 735
- End
- Begin CommandButton MemoryMinus
- Caption = "M-"
- Height = 375
- Left = 3120
- TabIndex = 30
- Tag = "Subtract displayed number from memory register"
- Top = 4260
- Width = 615
- End
- Begin CommandButton MemoryPlus
- Caption = "M+"
- Height = 375
- Left = 2400
- TabIndex = 29
- Tag = "Add displayed number to memory register"
- Top = 4260
- Width = 615
- End
- Begin CommandButton MemoryRecall
- Caption = "MR"
- Height = 375
- Left = 3120
- TabIndex = 28
- Tag = "Recall memory register as current entry"
- Top = 3840
- Width = 615
- End
- Begin CommandButton MemoryClear
- Caption = "MC"
- Height = 375
- Left = 2400
- TabIndex = 27
- Tag = "Clear Memory register"
- Top = 3840
- Width = 615
- End
- Begin CommandButton ClearEntry
- Caption = "CE"
- Height = 375
- Left = 3060
- TabIndex = 26
- Tag = "Clear Current Entry and reset total"
- Top = 2100
- Width = 615
- End
- Begin CommandButton Clear
- Caption = "C"
- Height = 375
- Left = 2400
- TabIndex = 25
- Tag = "Clear Current Entry"
- Top = 2100
- Width = 615
- End
- Begin SSOption Hex
- Caption = "Hex"
- Font3D = 0 'None
- Height = 255
- Left = 1560
- TabIndex = 22
- TabStop = 0 'False
- Tag = "Click o Select HEX data entry"
- Top = 900
- Width = 1215
- End
- Begin SSOption Decimal
- Caption = "Decimal"
- Font3D = 0 'None
- Height = 255
- Left = 240
- TabIndex = 21
- Tag = "Click tto Select Decimal data entry"
- Top = 900
- Value = -1 'True
- Width = 1215
- End
- Begin CommandButton Equal
- Caption = "="
- Height = 435
- Left = 2400
- TabIndex = 19
- Tag = "Show final result of calculation"
- Top = 3360
- Width = 1335
- End
- Begin CommandButton Minus
- Caption = "-"
- Height = 375
- Left = 3060
- TabIndex = 18
- Tag = "Subtract Current Entry from total"
- Top = 1260
- Width = 555
- End
- Begin CommandButton Plus
- Caption = "+"
- Height = 375
- Left = 2400
- TabIndex = 17
- Tag = "Add current entry to total"
- Top = 1260
- Width = 615
- End
- Begin CommandButton Digit
- Caption = "F"
- Height = 555
- Index = 15
- Left = 1500
- TabIndex = 16
- Top = 4080
- Width = 675
- End
- Begin CommandButton Digit
- Caption = "E"
- Height = 555
- Index = 14
- Left = 840
- TabIndex = 15
- Top = 4080
- Width = 675
- End
- Begin CommandButton Digit
- Caption = "D"
- Height = 555
- Index = 13
- Left = 180
- TabIndex = 14
- Top = 4080
- Width = 675
- End
- Begin CommandButton Digit
- Caption = "C"
- Height = 555
- Index = 12
- Left = 1500
- TabIndex = 13
- Top = 3540
- Width = 675
- End
- Begin CommandButton Digit
- Caption = "B"
- Height = 555
- Index = 11
- Left = 840
- TabIndex = 12
- Top = 3540
- Width = 675
- End
- Begin CommandButton Digit
- Caption = "A"
- Height = 555
- Index = 10
- Left = 180
- TabIndex = 11
- Top = 3540
- Width = 675
- End
- Begin CommandButton Digit
- Caption = "9"
- Height = 555
- Index = 9
- Left = 1560
- TabIndex = 10
- Top = 2340
- Width = 675
- End
- Begin CommandButton Digit
- Caption = "8"
- Height = 555
- Index = 8
- Left = 900
- TabIndex = 9
- Top = 2340
- Width = 675
- End
- Begin CommandButton Digit
- Caption = "7"
- Height = 555
- Index = 7
- Left = 240
- TabIndex = 8
- Top = 2340
- Width = 675
- End
- Begin CommandButton Digit
- Caption = "6"
- Height = 555
- Index = 6
- Left = 1560
- TabIndex = 7
- Top = 1800
- Width = 675
- End
- Begin CommandButton Digit
- Caption = "5"
- Height = 555
- Index = 5
- Left = 900
- TabIndex = 6
- Top = 1800
- Width = 675
- End
- Begin CommandButton Digit
- Caption = "4"
- Height = 555
- Index = 4
- Left = 240
- TabIndex = 5
- Top = 1800
- Width = 675
- End
- Begin CommandButton Digit
- Caption = "3"
- Height = 555
- Index = 3
- Left = 1560
- TabIndex = 4
- Top = 1260
- Width = 675
- End
- Begin CommandButton Digit
- Caption = "2"
- Height = 555
- Index = 2
- Left = 900
- TabIndex = 3
- Top = 1260
- Width = 675
- End
- Begin CommandButton Digit
- Caption = "1"
- Height = 555
- Index = 1
- Left = 240
- TabIndex = 2
- Tag = "Digits 1-9 and A-F are used to enter data"
- Top = 1260
- Width = 675
- End
- Begin CommandButton Digit
- Caption = "0"
- Height = 555
- Index = 0
- Left = 900
- TabIndex = 1
- Top = 2880
- Width = 675
- End
- Begin Label Label1
- BackColor = &H00C0C0C0&
- Caption = "Hex"
- Height = 255
- Index = 1
- Left = 240
- TabIndex = 24
- Top = 540
- Width = 795
- End
- Begin Label Label1
- BackColor = &H00C0C0C0&
- Caption = "Decimal"
- Height = 255
- Index = 0
- Left = 240
- TabIndex = 23
- Top = 240
- Width = 795
- End
- Begin Label HexDisplay
- BackColor = &H00FFFFFF&
- BorderStyle = 1 'Fixed Single
- ForeColor = &H00808080&
- Height = 315
- Left = 1080
- TabIndex = 20
- Tag = "Window To display HEX results"
- Top = 540
- Width = 2775
- End
- Begin Label DecDisplay
- BorderStyle = 1 'Fixed Single
- Height = 315
- Left = 1080
- TabIndex = 0
- Tag = "Window to display Decimal results"
- Top = 180
- Width = 2775
- End
- Begin Menu ID_FILE
- Caption = "&File"
- Begin Menu ID_EXIT
- Caption = "E&xit"
- End
- End
- Begin Menu ID_BOOL
- Caption = "&Boolean"
- Begin Menu ID_AND
- Caption = "&And"
- End
- Begin Menu ID_OR
- Caption = "&Or"
- End
- Begin Menu ID_NOT
- Caption = "&Not"
- End
- End
- Begin Menu ID_HELP
- Caption = "&Help"
- End
- Option Explicit
- Dim Result As Double
- Dim NewValue As Long
- Dim Memory As Long
- Dim BaseVal As Integer
- Dim Operation As Integer
- Const Add = 1
- Const Subtract = 2
- Const Multiply = 3
- Const Divide = 4
- Const BoolAnd = 5
- Const BoolOr = 6
- Const BoolNot = 7
- Const Exponent = 8
- Dim MAXVALUE As Long
- Sub ANDButton_Click ()
- Boolean BoolAnd
- End Sub
- Sub Boolean (BoolOp As Integer)
- Dim temp As Long
- If BoolOp = BoolNot Then
- temp = Len(HexDisplay) - 1
- temp = temp * 4
- temp = 2 ^ temp
- temp = temp - 1
- NewValue = Not NewValue And temp
- UpdateDisplay
- Else
- Result = NewValue
- NewValue = 0
- Operation = BoolOp
- End If
- End Sub
- Sub Clear_Click ()
- NewValue = 0
- Result = 0
- UpdateDisplay
- End Sub
- Sub ClearEntry_Click ()
- NewValue = 0
- UpdateDisplay
- End Sub
- Sub ComplementButton_Click ()
- Boolean BoolNot
- End Sub
- Sub Decimal_Click (Value As Integer)
- If Value = True Then
- BaseVal = 10
- HexDisplay.ForeColor = &H808080
- DecDisplay.ForeColor = 0
- End If
- End Sub
- Sub Digit_Click (index As Integer)
- If index >= BaseVal Then Exit Sub
- If NewValue > (MAXVALUE / BaseVal) Then
- Exit Sub
- Else
- NewValue = NewValue * BaseVal + index
- UpdateDisplay
- End If
- End Sub
- Sub Equal_Click ()
- Select Case Operation
- Case Add
- Result = Result + NewValue
- Case Subtract
- Result = Result - NewValue
- Case Multiply
- If MAXVALUE / NewValue >= Result Then
- Result = Result * NewValue
- End If
- Case Divide
- Result = Result / NewValue
- Case Exponent
- If NewValue < 30 Then
- Result = Result ^ NewValue
- End If
- Case BoolAnd
- Result = Result And NewValue
- Case BoolOr
- Result = Result Or NewValue
- End Select
- NewValue = 0
- ShowResult
- End Sub
- Sub Erase_Click ()
- Dim Length As Integer
- Dim Tmp As Integer, temp$
- Dim i As Integer
- NewValue = 0
- If BaseVal = 10 Then
- temp$ = DecDisplay
- Else
- temp$ = HexDisplay
- End If
- Length = Len(temp$)
- If Length > 1 Then
- For i = 1 To Length - 1
- Select Case Mid$(temp$, i, 1)
- Case "1"
- Tmp = 1
- Case "2"
- Tmp = 2
- Case "3"
- Tmp = 3
- Case "4"
- Tmp = 4
- Case "5"
- Tmp = 5
- Case "6"
- Tmp = 6
- Case "7"
- Tmp = 7
- Case "8"
- Tmp = 8
- Case "9"
- Tmp = 9
- Case "A"
- Tmp = 10
- Case "B"
- Tmp = 11
- Case "C"
- Tmp = 12
- Case "D"
- Tmp = 13
- Case "E"
- Tmp = 14
- Case "F"
- Tmp = 15
- End Select
- NewValue = NewValue * BaseVal + Tmp
- Next i
- End If
- UpdateDisplay
- End Sub
- Sub ExponButton_Click ()
- Operation = Exponent
- Result = NewValue
- NewValue = 0
- End Sub
- Sub Form_Load ()
- 'SetAppHelp Me.hWnd
- 'HelpWindowSize 128, 128, 700, 500
- Result = 0
- NewValue = 0
- Memory = 0
- BaseVal = 10
- MAXVALUE = &HFFFFFFF
- End Sub
- Sub Form_Unload (Cancel As Integer)
- 'QuitHelp
- End Sub
- Sub Hex_Click (Value As Integer)
- If Value = True Then
- BaseVal = 16
- HexDisplay.ForeColor = 0
- DecDisplay.ForeColor = &H808080
- End If
- End Sub
- Sub ID_AND_Click ()
- Boolean BoolAnd
- End Sub
- Sub ID_EXIT_Click ()
- Unload Me
- End Sub
- Sub ID_HELP_Click ()
- 'ShowHelpTopic Hlp_HexCalc_
- End Sub
- Sub ID_NOT_Click ()
- Boolean BoolNot
- End Sub
- Sub ID_OR_Click ()
- Boolean BoolOr
- End Sub
- Sub MemoryClear_Click ()
- Memory = 0
- End Sub
- Sub MemoryMinus_Click ()
- Memory = Memory - Val(DecDisplay)
- End Sub
- Sub MemoryPlus_Click ()
- Memory = Memory + Val(DecDisplay)
- End Sub
- Sub MemoryRecall_Click ()
- NewValue = Memory
- UpdateDisplay
- End Sub
- Sub Minus_Click ()
- Operation = Subtract
- Result = Result - NewValue
- NewValue = 0
- ShowResult
- End Sub
- Sub ORButton_Click ()
- Boolean BoolOr
- End Sub
- Sub Plus_Click ()
- Operation = Add
- Result = Result + NewValue
- NewValue = 0
- ShowResult
- End Sub
- Sub ShowResult ()
- DecDisplay = Str$(Result)
- HexDisplay = " " + Hex$(Result)
- End Sub
- Sub UpdateDisplay ()
- DecDisplay = Str$(NewValue)
- HexDisplay = " " + Hex$(NewValue)
- End Sub
-