home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / VISUAL_B / CODIGO_1 / CALCU_1 / CALC.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-07-14  |  20.6 KB  |  594 lines

  1. VERSION 2.00
  2. Begin Form Calculator 
  3.    BackColor       =   &H00000000&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "Calculator"
  6.    ClientHeight    =   4140
  7.    ClientLeft      =   2745
  8.    ClientTop       =   2085
  9.    ClientWidth     =   3705
  10.    ClipControls    =   0   'False
  11.    ControlBox      =   0   'False
  12.    FontBold        =   -1  'True
  13.    FontItalic      =   0   'False
  14.    FontName        =   "System"
  15.    FontSize        =   9.75
  16.    FontStrikethru  =   0   'False
  17.    FontUnderline   =   0   'False
  18.    Height          =   4545
  19.    Icon            =   CALC.FRX:0000
  20.    Left            =   2685
  21.    LinkMode        =   1  'Source
  22.    LinkTopic       =   "Form1"
  23.    MaxButton       =   0   'False
  24.    ScaleHeight     =   4140
  25.    ScaleWidth      =   3705
  26.    Top             =   1740
  27.    Width           =   3825
  28.    Begin SSPanel Panel3D2 
  29.       BevelInner      =   1  'Inset
  30.       BevelWidth      =   2
  31.       BorderWidth     =   6
  32.       FontBold        =   -1  'True
  33.       FontItalic      =   0   'False
  34.       FontName        =   "Wingdings"
  35.       FontSize        =   8.25
  36.       FontStrikethru  =   0   'False
  37.       FontUnderline   =   0   'False
  38.       ForeColor       =   &H00000000&
  39.       Height          =   3915
  40.       Left            =   75
  41.       TabIndex        =   1
  42.       Top             =   105
  43.       Width           =   3555
  44.       Begin SSPanel Panel3D5 
  45.          BevelInner      =   1  'Inset
  46.          BorderWidth     =   1
  47.          Height          =   375
  48.          Left            =   210
  49.          ShadowColor     =   1  'Black
  50.          TabIndex        =   24
  51.          Top             =   195
  52.          Width           =   1035
  53.          Begin SSPanel Panel3D7 
  54.             BackColor       =   &H0000FF00&
  55.             BevelInner      =   2  'Raised
  56.             BevelOuter      =   0  'None
  57.             BevelWidth      =   2
  58.             BorderWidth     =   1
  59.             Caption         =   "ON"
  60.             Font3D          =   1  'Raised w/light shading
  61.             FontBold        =   -1  'True
  62.             FontItalic      =   0   'False
  63.             FontName        =   "Arial"
  64.             FontSize        =   8.25
  65.             FontStrikethru  =   0   'False
  66.             FontUnderline   =   0   'False
  67.             ForeColor       =   &H00000000&
  68.             Height          =   285
  69.             Left            =   60
  70.             ShadowColor     =   1  'Black
  71.             TabIndex        =   25
  72.             Top             =   60
  73.             Width           =   450
  74.          End
  75.          Begin SSPanel Panel3D6 
  76.             BevelOuter      =   0  'None
  77.             BorderWidth     =   1
  78.             Caption         =   "OFF"
  79.             Font3D          =   3  'Inset w/light shading
  80.             FontBold        =   -1  'True
  81.             FontItalic      =   0   'False
  82.             FontName        =   "Arial"
  83.             FontSize        =   8.25
  84.             FontStrikethru  =   0   'False
  85.             FontUnderline   =   0   'False
  86.             ForeColor       =   &H000000FF&
  87.             Height          =   210
  88.             Left            =   570
  89.             ShadowColor     =   1  'Black
  90.             TabIndex        =   26
  91.             Top             =   90
  92.             Width           =   375
  93.          End
  94.       End
  95.       Begin SSPanel Panel3D4 
  96.          BevelInner      =   1  'Inset
  97.          BorderWidth     =   1
  98.          Caption         =   "CZAPPATRONICS"
  99.          Font3D          =   2  'Raised w/heavy shading
  100.          ForeColor       =   &H00FF0000&
  101.          Height          =   390
  102.          Left            =   1290
  103.          ShadowColor     =   1  'Black
  104.          TabIndex        =   23
  105.          Top             =   180
  106.          Width           =   2070
  107.       End
  108.       Begin SSPanel Panel3D3 
  109.          BackColor       =   &H00000000&
  110.          BevelOuter      =   1  'Inset
  111.          BevelWidth      =   2
  112.          BorderWidth     =   2
  113.          Height          =   525
  114.          Left            =   210
  115.          TabIndex        =   22
  116.          Top             =   615
  117.          Width           =   3150
  118.          Begin Label ReadOut 
  119.             Alignment       =   1  'Right Justify
  120.             BackColor       =   &H0000FFFF&
  121.             BorderStyle     =   1  'Fixed Single
  122.             Caption         =   "0."
  123.             FontBold        =   -1  'True
  124.             FontItalic      =   0   'False
  125.             FontName        =   "MS Sans Serif"
  126.             FontSize        =   13.5
  127.             FontStrikethru  =   0   'False
  128.             FontUnderline   =   0   'False
  129.             Height          =   420
  130.             Left            =   45
  131.             TabIndex        =   2
  132.             Top             =   60
  133.             Width           =   3075
  134.          End
  135.       End
  136.       Begin SSPanel Panel3D1 
  137.          BackColor       =   &H00808080&
  138.          BevelInner      =   2  'Raised
  139.          BorderWidth     =   1
  140.          Height          =   2520
  141.          Left            =   210
  142.          TabIndex        =   3
  143.          Top             =   1170
  144.          Width           =   3165
  145.          Begin CommandButton Number 
  146.             BackColor       =   &H00C0C0C0&
  147.             Caption         =   "7"
  148.             FontBold        =   -1  'True
  149.             FontItalic      =   0   'False
  150.             FontName        =   "System"
  151.             FontSize        =   9.75
  152.             FontStrikethru  =   0   'False
  153.             FontUnderline   =   0   'False
  154.             Height          =   480
  155.             Index           =   7
  156.             Left            =   90
  157.             TabIndex        =   0
  158.             Top             =   135
  159.             Width           =   480
  160.          End
  161.          Begin CommandButton Number 
  162.             BackColor       =   &H00C0C0C0&
  163.             Caption         =   "8"
  164.             FontBold        =   -1  'True
  165.             FontItalic      =   0   'False
  166.             FontName        =   "System"
  167.             FontSize        =   9.75
  168.             FontStrikethru  =   0   'False
  169.             FontUnderline   =   0   'False
  170.             Height          =   480
  171.             Index           =   8
  172.             Left            =   690
  173.             TabIndex        =   21
  174.             Top             =   135
  175.             Width           =   480
  176.          End
  177.          Begin CommandButton Number 
  178.             BackColor       =   &H00C0C0C0&
  179.             Caption         =   "9"
  180.             FontBold        =   -1  'True
  181.             FontItalic      =   0   'False
  182.             FontName        =   "System"
  183.             FontSize        =   9.75
  184.             FontStrikethru  =   0   'False
  185.             FontUnderline   =   0   'False
  186.             Height          =   480
  187.             Index           =   9
  188.             Left            =   1290
  189.             TabIndex        =   20
  190.             Top             =   135
  191.             Width           =   480
  192.          End
  193.          Begin CommandButton Cancel 
  194.             BackColor       =   &H00C0C0C0&
  195.             Caption         =   "C"
  196.             FontBold        =   -1  'True
  197.             FontItalic      =   0   'False
  198.             FontName        =   "System"
  199.             FontSize        =   9.75
  200.             FontStrikethru  =   0   'False
  201.             FontUnderline   =   0   'False
  202.             Height          =   480
  203.             Left            =   2010
  204.             TabIndex        =   19
  205.             Top             =   135
  206.             Width           =   480
  207.          End
  208.          Begin CommandButton CancelEntry 
  209.             BackColor       =   &H0000FFFF&
  210.             Caption         =   "CE"
  211.             FontBold        =   -1  'True
  212.             FontItalic      =   0   'False
  213.             FontName        =   "System"
  214.             FontSize        =   9.75
  215.             FontStrikethru  =   0   'False
  216.             FontUnderline   =   0   'False
  217.             Height          =   480
  218.             Left            =   2610
  219.             TabIndex        =   18
  220.             Top             =   135
  221.             Width           =   480
  222.          End
  223.          Begin CommandButton Number 
  224.             BackColor       =   &H00C0C0C0&
  225.             Caption         =   "4"
  226.             FontBold        =   -1  'True
  227.             FontItalic      =   0   'False
  228.             FontName        =   "System"
  229.             FontSize        =   9.75
  230.             FontStrikethru  =   0   'False
  231.             FontUnderline   =   0   'False
  232.             Height          =   480
  233.             Index           =   4
  234.             Left            =   90
  235.             TabIndex        =   17
  236.             Top             =   735
  237.             Width           =   480
  238.          End
  239.          Begin CommandButton Number 
  240.             BackColor       =   &H00C0C0C0&
  241.             Caption         =   "5"
  242.             FontBold        =   -1  'True
  243.             FontItalic      =   0   'False
  244.             FontName        =   "System"
  245.             FontSize        =   9.75
  246.             FontStrikethru  =   0   'False
  247.             FontUnderline   =   0   'False
  248.             Height          =   480
  249.             Index           =   5
  250.             Left            =   690
  251.             TabIndex        =   16
  252.             Top             =   735
  253.             Width           =   480
  254.          End
  255.          Begin CommandButton Number 
  256.             BackColor       =   &H00C0C0C0&
  257.             Caption         =   "6"
  258.             FontBold        =   -1  'True
  259.             FontItalic      =   0   'False
  260.             FontName        =   "System"
  261.             FontSize        =   9.75
  262.             FontStrikethru  =   0   'False
  263.             FontUnderline   =   0   'False
  264.             Height          =   480
  265.             Index           =   6
  266.             Left            =   1290
  267.             TabIndex        =   15
  268.             Top             =   735
  269.             Width           =   480
  270.          End
  271.          Begin CommandButton Operator 
  272.             BackColor       =   &H00C0C0C0&
  273.             Caption         =   "+"
  274.             FontBold        =   -1  'True
  275.             FontItalic      =   0   'False
  276.             FontName        =   "System"
  277.             FontSize        =   9.75
  278.             FontStrikethru  =   0   'False
  279.             FontUnderline   =   0   'False
  280.             Height          =   480
  281.             Index           =   1
  282.             Left            =   2010
  283.             TabIndex        =   14
  284.             Top             =   735
  285.             Width           =   480
  286.          End
  287.          Begin CommandButton Operator 
  288.             BackColor       =   &H00C0C0C0&
  289.             Caption         =   "-"
  290.             FontBold        =   -1  'True
  291.             FontItalic      =   0   'False
  292.             FontName        =   "System"
  293.             FontSize        =   9.75
  294.             FontStrikethru  =   0   'False
  295.             FontUnderline   =   0   'False
  296.             Height          =   480
  297.             Index           =   3
  298.             Left            =   2610
  299.             TabIndex        =   13
  300.             Top             =   735
  301.             Width           =   480
  302.          End
  303.          Begin CommandButton Number 
  304.             BackColor       =   &H00C0C0C0&
  305.             Caption         =   "1"
  306.             FontBold        =   -1  'True
  307.             FontItalic      =   0   'False
  308.             FontName        =   "System"
  309.             FontSize        =   9.75
  310.             FontStrikethru  =   0   'False
  311.             FontUnderline   =   0   'False
  312.             Height          =   480
  313.             Index           =   1
  314.             Left            =   90
  315.             TabIndex        =   12
  316.             Top             =   1335
  317.             Width           =   480
  318.          End
  319.          Begin CommandButton Number 
  320.             BackColor       =   &H00C0C0C0&
  321.             Caption         =   "2"
  322.             FontBold        =   -1  'True
  323.             FontItalic      =   0   'False
  324.             FontName        =   "System"
  325.             FontSize        =   9.75
  326.             FontStrikethru  =   0   'False
  327.             FontUnderline   =   0   'False
  328.             Height          =   480
  329.             Index           =   2
  330.             Left            =   690
  331.             TabIndex        =   11
  332.             Top             =   1335
  333.             Width           =   480
  334.          End
  335.          Begin CommandButton Number 
  336.             BackColor       =   &H00C0C0C0&
  337.             Caption         =   "3"
  338.             FontBold        =   -1  'True
  339.             FontItalic      =   0   'False
  340.             FontName        =   "System"
  341.             FontSize        =   9.75
  342.             FontStrikethru  =   0   'False
  343.             FontUnderline   =   0   'False
  344.             Height          =   480
  345.             Index           =   3
  346.             Left            =   1290
  347.             TabIndex        =   10
  348.             Top             =   1335
  349.             Width           =   480
  350.          End
  351.          Begin CommandButton Operator 
  352.             BackColor       =   &H00C0C0C0&
  353.             Caption         =   "X"
  354.             FontBold        =   -1  'True
  355.             FontItalic      =   0   'False
  356.             FontName        =   "System"
  357.             FontSize        =   9.75
  358.             FontStrikethru  =   0   'False
  359.             FontUnderline   =   0   'False
  360.             Height          =   480
  361.             Index           =   2
  362.             Left            =   2010
  363.             TabIndex        =   9
  364.             Top             =   1335
  365.             Width           =   480
  366.          End
  367.          Begin CommandButton Operator 
  368.             BackColor       =   &H00C0C0C0&
  369.             Caption         =   "/"
  370.             FontBold        =   -1  'True
  371.             FontItalic      =   0   'False
  372.             FontName        =   "System"
  373.             FontSize        =   9.75
  374.             FontStrikethru  =   0   'False
  375.             FontUnderline   =   0   'False
  376.             Height          =   480
  377.             Index           =   0
  378.             Left            =   2610
  379.             TabIndex        =   8
  380.             Top             =   1335
  381.             Width           =   480
  382.          End
  383.          Begin CommandButton Number 
  384.             BackColor       =   &H00C0C0C0&
  385.             Caption         =   "0"
  386.             FontBold        =   -1  'True
  387.             FontItalic      =   0   'False
  388.             FontName        =   "System"
  389.             FontSize        =   9.75
  390.             FontStrikethru  =   0   'False
  391.             FontUnderline   =   0   'False
  392.             Height          =   480
  393.             Index           =   0
  394.             Left            =   90
  395.             TabIndex        =   7
  396.             Top             =   1935
  397.             Width           =   1080
  398.          End
  399.          Begin CommandButton Decimal 
  400.             BackColor       =   &H00C0C0C0&
  401.             Caption         =   "."
  402.             FontBold        =   -1  'True
  403.             FontItalic      =   0   'False
  404.             FontName        =   "System"
  405.             FontSize        =   9.75
  406.             FontStrikethru  =   0   'False
  407.             FontUnderline   =   0   'False
  408.             Height          =   480
  409.             Left            =   1290
  410.             TabIndex        =   6
  411.             Top             =   1935
  412.             Width           =   480
  413.          End
  414.          Begin CommandButton Operator 
  415.             BackColor       =   &H00C0C0C0&
  416.             Caption         =   "="
  417.             FontBold        =   -1  'True
  418.             FontItalic      =   0   'False
  419.             FontName        =   "System"
  420.             FontSize        =   9.75
  421.             FontStrikethru  =   0   'False
  422.             FontUnderline   =   0   'False
  423.             Height          =   480
  424.             Index           =   4
  425.             Left            =   2010
  426.             TabIndex        =   5
  427.             Top             =   1935
  428.             Width           =   480
  429.          End
  430.          Begin CommandButton Percent 
  431.             BackColor       =   &H00C0C0C0&
  432.             Caption         =   "%"
  433.             FontBold        =   -1  'True
  434.             FontItalic      =   0   'False
  435.             FontName        =   "System"
  436.             FontSize        =   9.75
  437.             FontStrikethru  =   0   'False
  438.             FontUnderline   =   0   'False
  439.             Height          =   480
  440.             Left            =   2610
  441.             TabIndex        =   4
  442.             Top             =   1935
  443.             Width           =   480
  444.          End
  445.       End
  446.    End
  447. ' ------------------------------------------------------------------------
  448. '               Copyright (C) 1991 Microsoft Corporation
  449. ' You have a royalty-free right to use, modify, reproduce and distribute
  450. ' the Sample Application Files (and/or any modified version) in any way
  451. ' you find useful, provided that you agree that Microsoft has no warranty,
  452. ' obligations or liability for any Sample Application Files.
  453. ' ------------------------------------------------------------------------
  454. Option Explicit
  455. Dim Op1, Op2                ' Previously input operand.
  456. Dim DecimalFlag As Integer  ' Decimal point present yet?
  457. Dim NumOps As Integer       ' Number of operands.
  458. Dim LastInput               ' Indicate type of last keypress.
  459. Dim OpFlag                  ' Indicate pending operation.
  460. Dim TempReadout
  461. Dim MouseDownFlag As Integer
  462. Dim Counter As Integer
  463. ' Click event procedure for C (cancel) key.
  464. ' Reset the display and initializes variables.
  465. Sub Cancel_Click ()
  466.     ReadOut = "0."
  467.     Op1 = 0
  468.     Op2 = 0
  469.     Form_Load
  470. End Sub
  471. ' Click event procedure for CE (cancel entry) key.
  472. Sub CancelEntry_Click ()
  473.     ReadOut = "0."
  474.     DecimalFlag = False
  475.     LastInput = "CE"
  476. End Sub
  477. ' Click event procedure for decimal point (.) key.
  478. ' If last keypress was an operator, initialize
  479. ' readout to "0." Otherwise, append a decimal
  480. ' point to the display.
  481. Sub Decimal_Click ()
  482.     If LastInput = "NEG" Then
  483.     ReadOut = "-0."
  484.     ElseIf LastInput <> "NUMS" Then
  485.     ReadOut = "0."
  486.     End If
  487.     DecimalFlag = True
  488.     LastInput = "NUMS"
  489. End Sub
  490. ' Initialization routine for the form.
  491. ' Set all variables to initial values.
  492. Sub Form_Load ()
  493.     DecimalFlag = False
  494.     NumOps = 0
  495.     LastInput = "NONE"
  496.     OpFlag = " "
  497. End Sub
  498. ' Click event procedure for number keys (0-9).
  499. ' Appends new number to the number in the display.
  500. Sub Number_Click (Index As Integer)
  501.     If LastInput <> "NUMS" Then
  502.     ReadOut = "."
  503.     DecimalFlag = False
  504.     End If
  505.     If DecimalFlag Then
  506.     ReadOut = ReadOut + Number(Index).Caption
  507.     Else
  508.     ReadOut = Left(ReadOut, InStr(ReadOut, ".") - 1) + Number(Index).Caption + "."
  509.     End If
  510.     If LastInput = "NEG" Then ReadOut = "-" & ReadOut
  511.     LastInput = "NUMS"
  512. End Sub
  513. ' Click event procedure for operator keys (+, -, x, /, =).
  514. ' If the immediately preceeding keypress was part of a
  515. ' number, increment NumOps. If one operand is present,
  516. ' set Op1. If two are present, set Op1 equal to the
  517. ' result of the operation on Op1 and the current
  518. ' input string, and display the result.
  519. Sub Operator_Click (Index As Integer)
  520.     TempReadout = ReadOut
  521.     If LastInput = "NUMS" Then
  522.     NumOps = NumOps + 1
  523.     End If
  524.     Select Case NumOps
  525.     Case 0
  526.     If Operator(Index).Caption = "-" And LastInput <> "NEG" Then
  527.         ReadOut = "-" & ReadOut
  528.         LastInput = "NEG"
  529.     End If
  530.     Case 1
  531.     Op1 = ReadOut
  532.     If Operator(Index).Caption = "-" And LastInput <> "NUMS" And OpFlag <> "=" Then
  533.         ReadOut = "-"
  534.         LastInput = "NEG"
  535.     End If
  536.     Case 2
  537.     Op2 = TempReadout
  538.     Select Case OpFlag
  539.         Case "+"
  540.         Op1 = Val(Op1) + Val(Op2)
  541.         Case "-"
  542.         Op1 = Op1 - Op2
  543.         Case "X"
  544.         Op1 = Op1 * Op2
  545.         Case "/"
  546.         If Op2 = 0 Then
  547.            MsgBox "Can't divide by zero", 48, "Calculator"
  548.         Else
  549.            Op1 = Op1 / Op2
  550.         End If
  551.         Case "="
  552.         Op1 = Op2
  553.         Case "%"
  554.         Op1 = Op1 * Op2
  555.         End Select
  556.     ReadOut = Op1
  557.     NumOps = 1
  558.     End Select
  559.     If LastInput <> "NEG" Then
  560.     LastInput = "OPS"
  561.     OpFlag = Operator(Index).Caption
  562.     End If
  563. End Sub
  564. Sub Panel3D7_MouseDown (Button As Integer, Shift As Integer, x As Single, Y As Single)
  565. MouseDownFlag = True
  566. panel3d7.Font3D = 4
  567. End Sub
  568. Sub Panel3D7_MouseMove (Button As Integer, Shift As Integer, x As Single, Y As Single)
  569. If MouseDownFlag = True Then
  570.   If Counter > 10 Then
  571.     panel3d7.Left = x '+ (Command3d1.Width/4)
  572.     Counter = 0
  573.     If x > 400 Then
  574.       End
  575.     End If
  576.   Else
  577.     Counter = Counter + 1
  578.   End If
  579. End If
  580. End Sub
  581. Sub Panel3D7_MouseUp (Button As Integer, Shift As Integer, x As Single, Y As Single)
  582. MouseDownFlag = False
  583. panel3d7.Font3D = 1
  584. End Sub
  585. ' Click event procedure for percent key (%).
  586. ' Compute and display a percentage of the first operand.
  587. Sub Percent_Click ()
  588.     ReadOut = ReadOut / 100
  589.     LastInput = "Ops"
  590.     OpFlag = "%"
  591.     NumOps = NumOps + 1
  592.     DecimalFlag = True
  593. End Sub
  594.