home *** CD-ROM | disk | FTP | other *** search
/ On Hand / On_Hand_From_Softbank_1994_Release_2_Disc_2_1994.iso / 00202 / s / disk1 / calc.fr_ / calc.bin
Text File  |  1993-04-28  |  14KB  |  462 lines

  1. VERSION 2.00
  2. Begin Form Calculator 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Calculator"
  5.    ClipControls    =   0   'False
  6.    FontBold        =   -1  'True
  7.    FontItalic      =   0   'False
  8.    FontName        =   "System"
  9.    FontSize        =   9.75
  10.    FontStrikethru  =   0   'False
  11.    FontUnderline   =   0   'False
  12.    Height          =   3390
  13.    Icon            =   CALC.FRX:0000
  14.    Left            =   3075
  15.    LinkMode        =   1  'Source
  16.    LinkTopic       =   "Form1"
  17.    MaxButton       =   0   'False
  18.    ScaleHeight     =   2985
  19.    ScaleWidth      =   3240
  20.    Top             =   1665
  21.    Width           =   3360
  22.    Begin CommandButton Number 
  23.       Caption         =   "7"
  24.       FontBold        =   -1  'True
  25.       FontItalic      =   0   'False
  26.       FontName        =   "System"
  27.       FontSize        =   9.75
  28.       FontStrikethru  =   0   'False
  29.       FontUnderline   =   0   'False
  30.       Height          =   480
  31.       Index           =   7
  32.       Left            =   120
  33.       TabIndex        =   7
  34.       Top             =   600
  35.       Width           =   480
  36.    End
  37.    Begin CommandButton Number 
  38.       Caption         =   "8"
  39.       FontBold        =   -1  'True
  40.       FontItalic      =   0   'False
  41.       FontName        =   "System"
  42.       FontSize        =   9.75
  43.       FontStrikethru  =   0   'False
  44.       FontUnderline   =   0   'False
  45.       Height          =   480
  46.       Index           =   8
  47.       Left            =   720
  48.       TabIndex        =   8
  49.       Top             =   600
  50.       Width           =   480
  51.    End
  52.    Begin CommandButton Number 
  53.       Caption         =   "9"
  54.       FontBold        =   -1  'True
  55.       FontItalic      =   0   'False
  56.       FontName        =   "System"
  57.       FontSize        =   9.75
  58.       FontStrikethru  =   0   'False
  59.       FontUnderline   =   0   'False
  60.       Height          =   480
  61.       Index           =   9
  62.       Left            =   1320
  63.       TabIndex        =   9
  64.       Top             =   600
  65.       Width           =   480
  66.    End
  67.    Begin CommandButton Cancel 
  68.       Caption         =   "C"
  69.       FontBold        =   -1  'True
  70.       FontItalic      =   0   'False
  71.       FontName        =   "System"
  72.       FontSize        =   9.75
  73.       FontStrikethru  =   0   'False
  74.       FontUnderline   =   0   'False
  75.       Height          =   480
  76.       Left            =   2040
  77.       TabIndex        =   10
  78.       Top             =   600
  79.       Width           =   480
  80.    End
  81.    Begin CommandButton CancelEntry 
  82.       Caption         =   "CE"
  83.       FontBold        =   -1  'True
  84.       FontItalic      =   0   'False
  85.       FontName        =   "System"
  86.       FontSize        =   9.75
  87.       FontStrikethru  =   0   'False
  88.       FontUnderline   =   0   'False
  89.       Height          =   480
  90.       Left            =   2640
  91.       TabIndex        =   11
  92.       Top             =   600
  93.       Width           =   480
  94.    End
  95.    Begin CommandButton Number 
  96.       Caption         =   "4"
  97.       FontBold        =   -1  'True
  98.       FontItalic      =   0   'False
  99.       FontName        =   "System"
  100.       FontSize        =   9.75
  101.       FontStrikethru  =   0   'False
  102.       FontUnderline   =   0   'False
  103.       Height          =   480
  104.       Index           =   4
  105.       Left            =   120
  106.       TabIndex        =   4
  107.       Top             =   1200
  108.       Width           =   480
  109.    End
  110.    Begin CommandButton Number 
  111.       Caption         =   "5"
  112.       FontBold        =   -1  'True
  113.       FontItalic      =   0   'False
  114.       FontName        =   "System"
  115.       FontSize        =   9.75
  116.       FontStrikethru  =   0   'False
  117.       FontUnderline   =   0   'False
  118.       Height          =   480
  119.       Index           =   5
  120.       Left            =   720
  121.       TabIndex        =   5
  122.       Top             =   1200
  123.       Width           =   480
  124.    End
  125.    Begin CommandButton Number 
  126.       Caption         =   "6"
  127.       FontBold        =   -1  'True
  128.       FontItalic      =   0   'False
  129.       FontName        =   "System"
  130.       FontSize        =   9.75
  131.       FontStrikethru  =   0   'False
  132.       FontUnderline   =   0   'False
  133.       Height          =   480
  134.       Index           =   6
  135.       Left            =   1320
  136.       TabIndex        =   6
  137.       Top             =   1200
  138.       Width           =   480
  139.    End
  140.    Begin CommandButton Operator 
  141.       Caption         =   "+"
  142.       FontBold        =   -1  'True
  143.       FontItalic      =   0   'False
  144.       FontName        =   "System"
  145.       FontSize        =   9.75
  146.       FontStrikethru  =   0   'False
  147.       FontUnderline   =   0   'False
  148.       Height          =   480
  149.       Index           =   1
  150.       Left            =   2040
  151.       TabIndex        =   12
  152.       Top             =   1200
  153.       Width           =   480
  154.    End
  155.    Begin CommandButton Operator 
  156.       Caption         =   "-"
  157.       FontBold        =   -1  'True
  158.       FontItalic      =   0   'False
  159.       FontName        =   "System"
  160.       FontSize        =   9.75
  161.       FontStrikethru  =   0   'False
  162.       FontUnderline   =   0   'False
  163.       Height          =   480
  164.       Index           =   3
  165.       Left            =   2640
  166.       TabIndex        =   13
  167.       Top             =   1200
  168.       Width           =   480
  169.    End
  170.    Begin CommandButton Number 
  171.       Caption         =   "1"
  172.       FontBold        =   -1  'True
  173.       FontItalic      =   0   'False
  174.       FontName        =   "System"
  175.       FontSize        =   9.75
  176.       FontStrikethru  =   0   'False
  177.       FontUnderline   =   0   'False
  178.       Height          =   480
  179.       Index           =   1
  180.       Left            =   120
  181.       TabIndex        =   1
  182.       Top             =   1800
  183.       Width           =   480
  184.    End
  185.    Begin CommandButton Number 
  186.       Caption         =   "2"
  187.       FontBold        =   -1  'True
  188.       FontItalic      =   0   'False
  189.       FontName        =   "System"
  190.       FontSize        =   9.75
  191.       FontStrikethru  =   0   'False
  192.       FontUnderline   =   0   'False
  193.       Height          =   480
  194.       Index           =   2
  195.       Left            =   720
  196.       TabIndex        =   2
  197.       Top             =   1800
  198.       Width           =   480
  199.    End
  200.    Begin CommandButton Number 
  201.       Caption         =   "3"
  202.       FontBold        =   -1  'True
  203.       FontItalic      =   0   'False
  204.       FontName        =   "System"
  205.       FontSize        =   9.75
  206.       FontStrikethru  =   0   'False
  207.       FontUnderline   =   0   'False
  208.       Height          =   480
  209.       Index           =   3
  210.       Left            =   1320
  211.       TabIndex        =   3
  212.       Top             =   1800
  213.       Width           =   480
  214.    End
  215.    Begin CommandButton Operator 
  216.       Caption         =   "X"
  217.       FontBold        =   -1  'True
  218.       FontItalic      =   0   'False
  219.       FontName        =   "System"
  220.       FontSize        =   9.75
  221.       FontStrikethru  =   0   'False
  222.       FontUnderline   =   0   'False
  223.       Height          =   480
  224.       Index           =   2
  225.       Left            =   2040
  226.       TabIndex        =   14
  227.       Top             =   1800
  228.       Width           =   480
  229.    End
  230.    Begin CommandButton Operator 
  231.       Caption         =   "/"
  232.       FontBold        =   -1  'True
  233.       FontItalic      =   0   'False
  234.       FontName        =   "System"
  235.       FontSize        =   9.75
  236.       FontStrikethru  =   0   'False
  237.       FontUnderline   =   0   'False
  238.       Height          =   480
  239.       Index           =   0
  240.       Left            =   2640
  241.       TabIndex        =   15
  242.       Top             =   1800
  243.       Width           =   480
  244.    End
  245.    Begin CommandButton Number 
  246.       Caption         =   "0"
  247.       FontBold        =   -1  'True
  248.       FontItalic      =   0   'False
  249.       FontName        =   "System"
  250.       FontSize        =   9.75
  251.       FontStrikethru  =   0   'False
  252.       FontUnderline   =   0   'False
  253.       Height          =   480
  254.       Index           =   0
  255.       Left            =   120
  256.       TabIndex        =   0
  257.       Top             =   2400
  258.       Width           =   1080
  259.    End
  260.    Begin CommandButton Decimal 
  261.       Caption         =   "."
  262.       FontBold        =   -1  'True
  263.       FontItalic      =   0   'False
  264.       FontName        =   "System"
  265.       FontSize        =   9.75
  266.       FontStrikethru  =   0   'False
  267.       FontUnderline   =   0   'False
  268.       Height          =   480
  269.       Left            =   1320
  270.       TabIndex        =   18
  271.       Top             =   2400
  272.       Width           =   480
  273.    End
  274.    Begin CommandButton Operator 
  275.       Caption         =   "="
  276.       FontBold        =   -1  'True
  277.       FontItalic      =   0   'False
  278.       FontName        =   "System"
  279.       FontSize        =   9.75
  280.       FontStrikethru  =   0   'False
  281.       FontUnderline   =   0   'False
  282.       Height          =   480
  283.       Index           =   4
  284.       Left            =   2040
  285.       TabIndex        =   16
  286.       Top             =   2400
  287.       Width           =   480
  288.    End
  289.    Begin CommandButton Percent 
  290.       Caption         =   "%"
  291.       FontBold        =   -1  'True
  292.       FontItalic      =   0   'False
  293.       FontName        =   "System"
  294.       FontSize        =   9.75
  295.       FontStrikethru  =   0   'False
  296.       FontUnderline   =   0   'False
  297.       Height          =   480
  298.       Left            =   2640
  299.       TabIndex        =   17
  300.       Top             =   2400
  301.       Width           =   480
  302.    End
  303.    Begin Label Readout 
  304.       Alignment       =   1  'Right Justify
  305.       BackColor       =   &H0000FFFF&
  306.       BorderStyle     =   1  'Fixed Single
  307.       Caption         =   "0."
  308.       FontBold        =   -1  'True
  309.       FontItalic      =   0   'False
  310.       FontName        =   "MS Sans Serif"
  311.       FontSize        =   13.5
  312.       FontStrikethru  =   0   'False
  313.       FontUnderline   =   0   'False
  314.       ForeColor       =   &H00000000&
  315.       Height          =   375
  316.       Left            =   120
  317.       TabIndex        =   19
  318.       Top             =   105
  319.       Width           =   3000
  320.    End
  321. End
  322. ' ------------------------------------------------------------------------
  323. '               Copyright (C) 1991 Microsoft Corporation
  324. '
  325. ' You have a royalty-free right to use, modify, reproduce and distribute
  326. ' the Sample Application Files (and/or any modified version) in any way
  327. ' you find useful, provided that you agree that Microsoft has no warranty,
  328. ' obligations or liability for any Sample Application Files.
  329. ' ------------------------------------------------------------------------
  330. Option Explicit
  331. Dim Op1, Op2                ' Previously input operand.
  332. Dim DecimalFlag As Integer  ' Decimal point present yet?
  333. Dim NumOps As Integer       ' Number of operands.
  334. Dim LastInput               ' Indicate type of last keypress.
  335. Dim OpFlag                  ' Indicate pending operation.
  336. Dim TempReadout
  337.  
  338. ' Click event procedure for C (cancel) key.
  339. ' Reset the display and initializes variables.
  340. '
  341. Sub Cancel_Click ()
  342.     ReadOut = "0."
  343.     Op1 = 0
  344.     Op2 = 0
  345.     Form_Load
  346. End Sub
  347.  
  348. ' Click event procedure for CE (cancel entry) key.
  349. '
  350. Sub CancelEntry_Click ()
  351.     ReadOut = "0."
  352.     DecimalFlag = False
  353.     LastInput = "CE"
  354. End Sub
  355.  
  356. ' Click event procedure for decimal point (.) key.
  357. ' If last keypress was an operator, initialize
  358. ' readout to "0." Otherwise, append a decimal
  359. ' point to the display.
  360. '
  361. Sub Decimal_Click ()
  362.     If LastInput = "NEG" Then
  363.     ReadOut = "-0."
  364.     ElseIf LastInput <> "NUMS" Then
  365.     ReadOut = "0."
  366.     End If
  367.     DecimalFlag = True
  368.     LastInput = "NUMS"
  369. End Sub
  370.  
  371. ' Initialization routine for the form.
  372. ' Set all variables to initial values.
  373. '
  374. Sub Form_Load ()
  375.     DecimalFlag = False
  376.     NumOps = 0
  377.     LastInput = "NONE"
  378.     OpFlag = " "
  379. End Sub
  380.  
  381. ' Click event procedure for number keys (0-9).
  382. ' Appends new number to the number in the display.
  383. '
  384. Sub Number_Click (Index As Integer)
  385.     If LastInput <> "NUMS" Then
  386.     ReadOut = "."
  387.     DecimalFlag = False
  388.     End If
  389.     If DecimalFlag Then
  390.     ReadOut = ReadOut + Number(Index).Caption
  391.     Else
  392.     ReadOut = Left(ReadOut, InStr(ReadOut, ".") - 1) + Number(Index).Caption + "."
  393.     End If
  394.     If LastInput = "NEG" Then ReadOut = "-" & ReadOut
  395.     LastInput = "NUMS"
  396. End Sub
  397.  
  398. ' Click event procedure for operator keys (+, -, x, /, =).
  399. ' If the immediately preceeding keypress was part of a
  400. ' number, increment NumOps. If one operand is present,
  401. ' set Op1. If two are present, set Op1 equal to the
  402. ' result of the operation on Op1 and the current
  403. ' input string, and display the result.
  404. '
  405. Sub Operator_Click (Index As Integer)
  406.     TempReadout = ReadOut
  407.     If LastInput = "NUMS" Then
  408.     NumOps = NumOps + 1
  409.     End If
  410.     Select Case NumOps
  411.     Case 0
  412.     If Operator(Index).Caption = "-" And LastInput <> "NEG" Then
  413.         ReadOut = "-" & ReadOut
  414.         LastInput = "NEG"
  415.     End If
  416.     Case 1
  417.     Op1 = ReadOut
  418.     If Operator(Index).Caption = "-" And LastInput <> "NUMS" And OpFlag <> "=" Then
  419.         ReadOut = "-"
  420.         LastInput = "NEG"
  421.     End If
  422.     Case 2
  423.     Op2 = TempReadout
  424.     Select Case OpFlag
  425.         Case "+"
  426.         Op1 = Val(Op1) + Val(Op2)
  427.         Case "-"
  428.         Op1 = Op1 - Op2
  429.         Case "X"
  430.         Op1 = Op1 * Op2
  431.         Case "/"
  432.         If Op2 = 0 Then
  433.            MsgBox "Can't divide by zero", 48, "Calculator"
  434.         Else
  435.            Op1 = Op1 / Op2
  436.         End If
  437.         Case "="
  438.         Op1 = Op2
  439.         Case "%"
  440.         Op1 = Op1 * Op2
  441.         End Select
  442.     ReadOut = Op1
  443.     NumOps = 1
  444.     End Select
  445.     If LastInput <> "NEG" Then
  446.     LastInput = "OPS"
  447.     OpFlag = Operator(Index).Caption
  448.     End If
  449. End Sub
  450.  
  451. ' Click event procedure for percent key (%).
  452. ' Compute and display a percentage of the first operand.
  453. '
  454. Sub Percent_Click ()
  455.     ReadOut = ReadOut / 100
  456.     LastInput = "Ops"
  457.     OpFlag = "%"
  458.     NumOps = NumOps + 1
  459.     DecimalFlag = True
  460. End Sub
  461.  
  462.