home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / VISUAL_B / FERRAMEN / VBHW / HEXCALC.FR_ / HEXCALC.FR (.txt)
Encoding:
Visual Basic Form  |  1993-11-17  |  16.2 KB  |  600 lines

  1. VERSION 2.00
  2. Begin Form HexCalcFrm 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "HexCalc"
  6.    ClientHeight    =   4740
  7.    ClientLeft      =   3060
  8.    ClientTop       =   2505
  9.    ClientWidth     =   3945
  10.    Height          =   5430
  11.    Icon            =   HEXCALC.FRX:0000
  12.    Left            =   3000
  13.    LinkTopic       =   "Form1"
  14.    ScaleHeight     =   540
  15.    ScaleWidth      =   540
  16.    Top             =   1875
  17.    Width           =   4065
  18.    Begin CommandButton ExponButton 
  19.       Caption         =   "^"
  20.       Height          =   375
  21.       Left            =   3060
  22.       TabIndex        =   37
  23.       Tag             =   "Exponentiation"
  24.       Top             =   2940
  25.       Width           =   615
  26.    End
  27.    Begin CommandButton DivButton 
  28.       Caption         =   "/"
  29.       Height          =   375
  30.       Left            =   3060
  31.       TabIndex        =   36
  32.       Tag             =   "Divide current value"
  33.       Top             =   1680
  34.       Width           =   615
  35.    End
  36.    Begin CommandButton MultButton 
  37.       Caption         =   "X"
  38.       Height          =   375
  39.       Left            =   2400
  40.       TabIndex        =   35
  41.       Tag             =   "Multiply current value"
  42.       Top             =   1680
  43.       Width           =   615
  44.    End
  45.    Begin CommandButton ComplementButton 
  46.       Caption         =   "Not"
  47.       Height          =   375
  48.       Left            =   2400
  49.       TabIndex        =   34
  50.       Tag             =   "Perform Boolean complement"
  51.       Top             =   2940
  52.       Width           =   615
  53.    End
  54.    Begin CommandButton ORButton 
  55.       Caption         =   "OR"
  56.       Height          =   375
  57.       Left            =   3060
  58.       TabIndex        =   33
  59.       Tag             =   "Perform Boolean OR operation"
  60.       Top             =   2520
  61.       Width           =   615
  62.    End
  63.    Begin CommandButton ANDButton 
  64.       Caption         =   "And"
  65.       Height          =   375
  66.       Left            =   2400
  67.       TabIndex        =   32
  68.       Tag             =   "Perform Boolean AND operation"
  69.       Top             =   2520
  70.       Width           =   615
  71.    End
  72.    Begin CommandButton Erase 
  73.       Caption         =   "<-"
  74.       Height          =   315
  75.       Left            =   2940
  76.       TabIndex        =   31
  77.       Tag             =   "Erase last character entered"
  78.       Top             =   900
  79.       Width           =   735
  80.    End
  81.    Begin CommandButton MemoryMinus 
  82.       Caption         =   "M-"
  83.       Height          =   375
  84.       Left            =   3120
  85.       TabIndex        =   30
  86.       Tag             =   "Subtract displayed number from memory register"
  87.       Top             =   4260
  88.       Width           =   615
  89.    End
  90.    Begin CommandButton MemoryPlus 
  91.       Caption         =   "M+"
  92.       Height          =   375
  93.       Left            =   2400
  94.       TabIndex        =   29
  95.       Tag             =   "Add displayed number to memory register"
  96.       Top             =   4260
  97.       Width           =   615
  98.    End
  99.    Begin CommandButton MemoryRecall 
  100.       Caption         =   "MR"
  101.       Height          =   375
  102.       Left            =   3120
  103.       TabIndex        =   28
  104.       Tag             =   "Recall memory register as current entry"
  105.       Top             =   3840
  106.       Width           =   615
  107.    End
  108.    Begin CommandButton MemoryClear 
  109.       Caption         =   "MC"
  110.       Height          =   375
  111.       Left            =   2400
  112.       TabIndex        =   27
  113.       Tag             =   "Clear Memory register"
  114.       Top             =   3840
  115.       Width           =   615
  116.    End
  117.    Begin CommandButton ClearEntry 
  118.       Caption         =   "CE"
  119.       Height          =   375
  120.       Left            =   3060
  121.       TabIndex        =   26
  122.       Tag             =   "Clear Current Entry and reset total"
  123.       Top             =   2100
  124.       Width           =   615
  125.    End
  126.    Begin CommandButton Clear 
  127.       Caption         =   "C"
  128.       Height          =   375
  129.       Left            =   2400
  130.       TabIndex        =   25
  131.       Tag             =   "Clear Current Entry"
  132.       Top             =   2100
  133.       Width           =   615
  134.    End
  135.    Begin SSOption Hex 
  136.       Caption         =   "Hex"
  137.       Font3D          =   0  'None
  138.       Height          =   255
  139.       Left            =   1560
  140.       TabIndex        =   22
  141.       TabStop         =   0   'False
  142.       Tag             =   "Click o Select HEX data entry"
  143.       Top             =   900
  144.       Width           =   1215
  145.    End
  146.    Begin SSOption Decimal 
  147.       Caption         =   "Decimal"
  148.       Font3D          =   0  'None
  149.       Height          =   255
  150.       Left            =   240
  151.       TabIndex        =   21
  152.       Tag             =   "Click tto Select Decimal data entry"
  153.       Top             =   900
  154.       Value           =   -1  'True
  155.       Width           =   1215
  156.    End
  157.    Begin CommandButton Equal 
  158.       Caption         =   "="
  159.       Height          =   435
  160.       Left            =   2400
  161.       TabIndex        =   19
  162.       Tag             =   "Show final result of calculation"
  163.       Top             =   3360
  164.       Width           =   1335
  165.    End
  166.    Begin CommandButton Minus 
  167.       Caption         =   "-"
  168.       Height          =   375
  169.       Left            =   3060
  170.       TabIndex        =   18
  171.       Tag             =   "Subtract Current Entry from total"
  172.       Top             =   1260
  173.       Width           =   555
  174.    End
  175.    Begin CommandButton Plus 
  176.       Caption         =   "+"
  177.       Height          =   375
  178.       Left            =   2400
  179.       TabIndex        =   17
  180.       Tag             =   "Add current entry to total"
  181.       Top             =   1260
  182.       Width           =   615
  183.    End
  184.    Begin CommandButton Digit 
  185.       Caption         =   "F"
  186.       Height          =   555
  187.       Index           =   15
  188.       Left            =   1500
  189.       TabIndex        =   16
  190.       Top             =   4080
  191.       Width           =   675
  192.    End
  193.    Begin CommandButton Digit 
  194.       Caption         =   "E"
  195.       Height          =   555
  196.       Index           =   14
  197.       Left            =   840
  198.       TabIndex        =   15
  199.       Top             =   4080
  200.       Width           =   675
  201.    End
  202.    Begin CommandButton Digit 
  203.       Caption         =   "D"
  204.       Height          =   555
  205.       Index           =   13
  206.       Left            =   180
  207.       TabIndex        =   14
  208.       Top             =   4080
  209.       Width           =   675
  210.    End
  211.    Begin CommandButton Digit 
  212.       Caption         =   "C"
  213.       Height          =   555
  214.       Index           =   12
  215.       Left            =   1500
  216.       TabIndex        =   13
  217.       Top             =   3540
  218.       Width           =   675
  219.    End
  220.    Begin CommandButton Digit 
  221.       Caption         =   "B"
  222.       Height          =   555
  223.       Index           =   11
  224.       Left            =   840
  225.       TabIndex        =   12
  226.       Top             =   3540
  227.       Width           =   675
  228.    End
  229.    Begin CommandButton Digit 
  230.       Caption         =   "A"
  231.       Height          =   555
  232.       Index           =   10
  233.       Left            =   180
  234.       TabIndex        =   11
  235.       Top             =   3540
  236.       Width           =   675
  237.    End
  238.    Begin CommandButton Digit 
  239.       Caption         =   "9"
  240.       Height          =   555
  241.       Index           =   9
  242.       Left            =   1560
  243.       TabIndex        =   10
  244.       Top             =   2340
  245.       Width           =   675
  246.    End
  247.    Begin CommandButton Digit 
  248.       Caption         =   "8"
  249.       Height          =   555
  250.       Index           =   8
  251.       Left            =   900
  252.       TabIndex        =   9
  253.       Top             =   2340
  254.       Width           =   675
  255.    End
  256.    Begin CommandButton Digit 
  257.       Caption         =   "7"
  258.       Height          =   555
  259.       Index           =   7
  260.       Left            =   240
  261.       TabIndex        =   8
  262.       Top             =   2340
  263.       Width           =   675
  264.    End
  265.    Begin CommandButton Digit 
  266.       Caption         =   "6"
  267.       Height          =   555
  268.       Index           =   6
  269.       Left            =   1560
  270.       TabIndex        =   7
  271.       Top             =   1800
  272.       Width           =   675
  273.    End
  274.    Begin CommandButton Digit 
  275.       Caption         =   "5"
  276.       Height          =   555
  277.       Index           =   5
  278.       Left            =   900
  279.       TabIndex        =   6
  280.       Top             =   1800
  281.       Width           =   675
  282.    End
  283.    Begin CommandButton Digit 
  284.       Caption         =   "4"
  285.       Height          =   555
  286.       Index           =   4
  287.       Left            =   240
  288.       TabIndex        =   5
  289.       Top             =   1800
  290.       Width           =   675
  291.    End
  292.    Begin CommandButton Digit 
  293.       Caption         =   "3"
  294.       Height          =   555
  295.       Index           =   3
  296.       Left            =   1560
  297.       TabIndex        =   4
  298.       Top             =   1260
  299.       Width           =   675
  300.    End
  301.    Begin CommandButton Digit 
  302.       Caption         =   "2"
  303.       Height          =   555
  304.       Index           =   2
  305.       Left            =   900
  306.       TabIndex        =   3
  307.       Top             =   1260
  308.       Width           =   675
  309.    End
  310.    Begin CommandButton Digit 
  311.       Caption         =   "1"
  312.       Height          =   555
  313.       Index           =   1
  314.       Left            =   240
  315.       TabIndex        =   2
  316.       Tag             =   "Digits 1-9 and A-F are used to enter data"
  317.       Top             =   1260
  318.       Width           =   675
  319.    End
  320.    Begin CommandButton Digit 
  321.       Caption         =   "0"
  322.       Height          =   555
  323.       Index           =   0
  324.       Left            =   900
  325.       TabIndex        =   1
  326.       Top             =   2880
  327.       Width           =   675
  328.    End
  329.    Begin Label Label1 
  330.       BackColor       =   &H00C0C0C0&
  331.       Caption         =   "Hex"
  332.       Height          =   255
  333.       Index           =   1
  334.       Left            =   240
  335.       TabIndex        =   24
  336.       Top             =   540
  337.       Width           =   795
  338.    End
  339.    Begin Label Label1 
  340.       BackColor       =   &H00C0C0C0&
  341.       Caption         =   "Decimal"
  342.       Height          =   255
  343.       Index           =   0
  344.       Left            =   240
  345.       TabIndex        =   23
  346.       Top             =   240
  347.       Width           =   795
  348.    End
  349.    Begin Label HexDisplay 
  350.       BackColor       =   &H00FFFFFF&
  351.       BorderStyle     =   1  'Fixed Single
  352.       ForeColor       =   &H00808080&
  353.       Height          =   315
  354.       Left            =   1080
  355.       TabIndex        =   20
  356.       Tag             =   "Window To display HEX results"
  357.       Top             =   540
  358.       Width           =   2775
  359.    End
  360.    Begin Label DecDisplay 
  361.       BorderStyle     =   1  'Fixed Single
  362.       Height          =   315
  363.       Left            =   1080
  364.       TabIndex        =   0
  365.       Tag             =   "Window to display Decimal results"
  366.       Top             =   180
  367.       Width           =   2775
  368.    End
  369.    Begin Menu ID_FILE 
  370.       Caption         =   "&File"
  371.       Begin Menu ID_EXIT 
  372.          Caption         =   "E&xit"
  373.       End
  374.    End
  375.    Begin Menu ID_BOOL 
  376.       Caption         =   "&Boolean"
  377.       Begin Menu ID_AND 
  378.          Caption         =   "&And"
  379.       End
  380.       Begin Menu ID_OR 
  381.          Caption         =   "&Or"
  382.       End
  383.       Begin Menu ID_NOT 
  384.          Caption         =   "&Not"
  385.       End
  386.    End
  387.    Begin Menu ID_HELP 
  388.       Caption         =   "&Help"
  389.    End
  390. Option Explicit
  391. Dim Result As Double
  392. Dim NewValue As Long
  393. Dim Memory As Long
  394. Dim BaseVal As Integer
  395. Dim Operation As Integer
  396. Const Add = 1
  397. Const Subtract = 2
  398. Const Multiply = 3
  399. Const Divide = 4
  400. Const BoolAnd = 5
  401. Const BoolOr = 6
  402. Const BoolNot = 7
  403. Const Exponent = 8
  404. Dim MAXVALUE As Long
  405. Sub ANDButton_Click ()
  406.     Boolean BoolAnd
  407. End Sub
  408. Sub Boolean (BoolOp As Integer)
  409.      Dim temp As Long
  410.     If BoolOp = BoolNot Then
  411.         temp = Len(HexDisplay) - 1
  412.         temp = temp * 4
  413.         temp = 2 ^ temp
  414.         temp = temp - 1
  415.         NewValue = Not NewValue And temp
  416.         UpdateDisplay
  417.     Else
  418.         Result = NewValue
  419.         NewValue = 0
  420.         Operation = BoolOp
  421.     End If
  422. End Sub
  423. Sub Clear_Click ()
  424.     NewValue = 0
  425.     Result = 0
  426.     UpdateDisplay
  427. End Sub
  428. Sub ClearEntry_Click ()
  429.     NewValue = 0
  430.     UpdateDisplay
  431. End Sub
  432. Sub ComplementButton_Click ()
  433.     Boolean BoolNot
  434. End Sub
  435. Sub Decimal_Click (Value As Integer)
  436.     If Value = True Then
  437.         BaseVal = 10
  438.         HexDisplay.ForeColor = &H808080
  439.         DecDisplay.ForeColor = 0
  440.     End If
  441. End Sub
  442. Sub Digit_Click (index As Integer)
  443.     If index >= BaseVal Then Exit Sub
  444.     If NewValue > (MAXVALUE / BaseVal) Then
  445.         Exit Sub
  446.     Else
  447.         NewValue = NewValue * BaseVal + index
  448.         UpdateDisplay
  449.     End If
  450. End Sub
  451. Sub Equal_Click ()
  452.     Select Case Operation
  453.     Case Add
  454.         Result = Result + NewValue
  455.     Case Subtract
  456.         Result = Result - NewValue
  457.     Case Multiply
  458.         If MAXVALUE / NewValue >= Result Then
  459.             Result = Result * NewValue
  460.         End If
  461.     Case Divide
  462.         Result = Result / NewValue
  463.     Case Exponent
  464.         If NewValue < 30 Then
  465.             Result = Result ^ NewValue
  466.         End If
  467.     Case BoolAnd
  468.         Result = Result And NewValue
  469.     Case BoolOr
  470.         Result = Result Or NewValue
  471.     End Select
  472.     NewValue = 0
  473.     ShowResult
  474. End Sub
  475. Sub Erase_Click ()
  476.     Dim Length As Integer
  477.     Dim Tmp As Integer, temp$
  478.     Dim i As Integer
  479.     NewValue = 0
  480.     If BaseVal = 10 Then
  481.         temp$ = DecDisplay
  482.     Else
  483.         temp$ = HexDisplay
  484.     End If
  485.     Length = Len(temp$)
  486.     If Length > 1 Then
  487.         For i = 1 To Length - 1
  488.             Select Case Mid$(temp$, i, 1)
  489.             Case "1"
  490.                 Tmp = 1
  491.             Case "2"
  492.                 Tmp = 2
  493.             Case "3"
  494.                 Tmp = 3
  495.             Case "4"
  496.                 Tmp = 4
  497.             Case "5"
  498.                 Tmp = 5
  499.             Case "6"
  500.                 Tmp = 6
  501.             Case "7"
  502.                 Tmp = 7
  503.             Case "8"
  504.                 Tmp = 8
  505.             Case "9"
  506.                 Tmp = 9
  507.             Case "A"
  508.                 Tmp = 10
  509.             Case "B"
  510.                 Tmp = 11
  511.             Case "C"
  512.                 Tmp = 12
  513.             Case "D"
  514.                 Tmp = 13
  515.             Case "E"
  516.                 Tmp = 14
  517.             Case "F"
  518.                 Tmp = 15
  519.             End Select
  520.             NewValue = NewValue * BaseVal + Tmp
  521.         Next i
  522.     End If
  523.     UpdateDisplay
  524. End Sub
  525. Sub ExponButton_Click ()
  526.     Operation = Exponent
  527.     Result = NewValue
  528.     NewValue = 0
  529. End Sub
  530. Sub Form_Load ()
  531.     'SetAppHelp Me.hWnd
  532.     'HelpWindowSize 128, 128, 700, 500
  533.     Result = 0
  534.     NewValue = 0
  535.     Memory = 0
  536.     BaseVal = 10
  537.     MAXVALUE = &HFFFFFFF
  538. End Sub
  539. Sub Form_Unload (Cancel As Integer)
  540.     'QuitHelp
  541. End Sub
  542. Sub Hex_Click (Value As Integer)
  543.     If Value = True Then
  544.         BaseVal = 16
  545.         HexDisplay.ForeColor = 0
  546.         DecDisplay.ForeColor = &H808080
  547.     End If
  548. End Sub
  549. Sub ID_AND_Click ()
  550.     Boolean BoolAnd
  551. End Sub
  552. Sub ID_EXIT_Click ()
  553.     Unload Me
  554. End Sub
  555. Sub ID_HELP_Click ()
  556.     'ShowHelpTopic Hlp_HexCalc_
  557. End Sub
  558. Sub ID_NOT_Click ()
  559.     Boolean BoolNot
  560. End Sub
  561. Sub ID_OR_Click ()
  562.     Boolean BoolOr
  563. End Sub
  564. Sub MemoryClear_Click ()
  565.     Memory = 0
  566. End Sub
  567. Sub MemoryMinus_Click ()
  568.     Memory = Memory - Val(DecDisplay)
  569. End Sub
  570. Sub MemoryPlus_Click ()
  571.     Memory = Memory + Val(DecDisplay)
  572. End Sub
  573. Sub MemoryRecall_Click ()
  574.     NewValue = Memory
  575.     UpdateDisplay
  576. End Sub
  577. Sub Minus_Click ()
  578.     Operation = Subtract
  579.     Result = Result - NewValue
  580.     NewValue = 0
  581.     ShowResult
  582. End Sub
  583. Sub ORButton_Click ()
  584.     Boolean BoolOr
  585. End Sub
  586. Sub Plus_Click ()
  587.     Operation = Add
  588.     Result = Result + NewValue
  589.     NewValue = 0
  590.     ShowResult
  591. End Sub
  592. Sub ShowResult ()
  593.     DecDisplay = Str$(Result)
  594.     HexDisplay = " " + Hex$(Result)
  595. End Sub
  596. Sub UpdateDisplay ()
  597.     DecDisplay = Str$(NewValue)
  598.     HexDisplay = " " + Hex$(NewValue)
  599. End Sub
  600.