home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / VISUAL_B / CODIGO_1 / CALCU_2 / CALC.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1992-12-08  |  17.8 KB  |  537 lines

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