Stuck? Need help? Ask questions on our forums.

View \MathCalc.frm

Calculation-Cal-Comp v1.0

Submitted By: Akshay Minocha
Rating: (Not rated) (Rate It)


VERSION 5.00
Begin VB.Form MathCalc
   BackColor       =   &H80000009&
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Math Calculator - By Akshay Minocha"
   ClientHeight    =   5715
   ClientLeft      =   3180
   ClientTop       =   1455
   ClientWidth     =   4995
   FillColor       =   &H00FFFFFF&
   BeginProperty Font
      Name            =   "Verdana"
      Size            =   9.75
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   ForeColor       =   &H8000000E&
   LinkTopic       =   "Form2"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   Picture         =   "MathCalc.frx":0000
   ScaleHeight     =   5715
   ScaleWidth      =   4995
   Begin VB.CommandButton Over
      BackColor       =   &H80000009&
      Caption         =   "1/X"
      Height          =   1650
      Left            =   840
      MaskColor       =   &H00FFFFFF&
      Picture         =   "MathCalc.frx":24B9
      Style           =   1  'Graphical
      TabIndex        =   21
      Top             =   1080
      Width           =   705
   End
   Begin VB.CommandButton Command2
      BackColor       =   &H80000009&
      Caption         =   " H O M E"
      Height          =   975
      Left            =   0
      MaskColor       =   &H00FFFFFF&
      Style           =   1  'Graphical
      TabIndex        =   20
      Top             =   2760
      Width           =   1575
   End
   Begin VB.CommandButton Command1
      BackColor       =   &H80000009&
      Caption         =   "EXIT"
      Height          =   1695
      Left            =   0
      MaskColor       =   &H00FFFFFF&
      Style           =   1  'Graphical
      TabIndex        =   19
      Top             =   1080
      Width           =   855
   End
   Begin VB.CommandButton PlusMinus
      BackColor       =   &H80000009&
      Caption         =   "+/-"
      Height          =   1650
      Left            =   1560
      MaskColor       =   &H80000009&
      Picture         =   "MathCalc.frx":4ABC
      Style           =   1  'Graphical
      TabIndex        =   18
      Top             =   1080
      Width           =   825
   End
   Begin VB.CommandButton Digits
      BackColor       =   &H80000009&
      Caption         =   "1"
      Height          =   1050
      Index           =   1
      Left            =   1560
      MaskColor       =   &H80000005&
      Picture         =   "MathCalc.frx":6FF7
      Style           =   1  'Graphical
      TabIndex        =   17
      Top             =   2760
      Width           =   825
   End
   Begin VB.CommandButton Digits
      BackColor       =   &H80000009&
      Caption         =   "2"
      Height          =   1050
      Index           =   2
      Left            =   2400
      MaskColor       =   &H00FFFFFF&
      Picture         =   "MathCalc.frx":9240
      Style           =   1  'Graphical
      TabIndex        =   16
      Top             =   2760
      Width           =   825
   End
   Begin VB.CommandButton Digits
      BackColor       =   &H80000009&
      Caption         =   "3"
      Height          =   930
      Index           =   3
      Left            =   0
      MaskColor       =   &H80000009&
      Picture         =   "MathCalc.frx":B631
      Style           =   1  'Graphical
      TabIndex        =   15
      Top             =   3840
      Width           =   705
   End
   Begin VB.CommandButton Equals
      BackColor       =   &H80000009&
      Caption         =   "="
      Height          =   2970
      Left            =   4080
      MaskColor       =   &H00FFFFFF&
      Picture         =   "MathCalc.frx":DAAC
      Style           =   1  'Graphical
      TabIndex        =   14
      Top             =   2760
      Width           =   975
   End
   Begin VB.CommandButton Div
      BackColor       =   &H80000009&
      Caption         =   "/"
      Height          =   1650
      Left            =   3240
      MaskColor       =   &H00FFFFFF&
      Picture         =   "MathCalc.frx":FE41
      Style           =   1  'Graphical
      TabIndex        =   13
      Top             =   1080
      Width           =   825
   End
   Begin VB.CommandButton Times
      BackColor       =   &H80000009&
      Caption         =   "*"
      Height          =   2010
      Left            =   3240
      MaskColor       =   &H00FFFFFF&
      Picture         =   "MathCalc.frx":121D6
      Style           =   1  'Graphical
      TabIndex        =   12
      Top             =   2760
      Width           =   825
   End
   Begin VB.CommandButton Minus
      BackColor       =   &H80000009&
      Caption         =   "-"
      Height          =   1650
      Left            =   2400
      MaskColor       =   &H80000009&
      Picture         =   "MathCalc.frx":14732
      Style           =   1  'Graphical
      TabIndex        =   11
      Top             =   1080
      Width           =   825
   End
   Begin VB.CommandButton Plus
      BackColor       =   &H80000005&
      Caption         =   "+"
      DownPicture     =   "MathCalc.frx":1692A
      Height          =   1650
      Left            =   4080
      MaskColor       =   &H00FFFFFF&
      Picture         =   "MathCalc.frx":193ED
      Style           =   1  'Graphical
      TabIndex        =   10
      ToolTipText     =   "Adds the Values Entered"
      Top             =   1080
      Width           =   945
   End
   Begin VB.CommandButton ClearBttn
      BackColor       =   &H80000009&
      Caption         =   "C"
      Height          =   930
      Left            =   3960
      MaskColor       =   &H00FFFFFF&
      Picture         =   "MathCalc.frx":1B7C0
      Style           =   1  'Graphical
      TabIndex        =   9
      Top             =   120
      Width           =   1065
   End
   Begin VB.CommandButton DotBttn
      BackColor       =   &H80000009&
      Caption         =   "."
      Height          =   930
      Left            =   3240
      MaskColor       =   &H00FFFFFF&
      Picture         =   "MathCalc.frx":1DC80
      Style           =   1  'Graphical
      TabIndex        =   8
      Top             =   4800
      Width           =   825
   End
   Begin VB.CommandButton Digits
      BackColor       =   &H80000009&
      Caption         =   "9"
      Height          =   930
      Index           =   9
      Left            =   1560
      MaskColor       =   &H80000009&
      Picture         =   "MathCalc.frx":1FF4F
      Style           =   1  'Graphical
      TabIndex        =   7
      Top             =   4800
      Width           =   825
   End
   Begin VB.CommandButton Digits
      BackColor       =   &H80000009&
      Caption         =   "8"
      Height          =   930
      Index           =   8
      Left            =   720
      MaskColor       =   &H80000009&
      Picture         =   "MathCalc.frx":223D8
      Style           =   1  'Graphical
      TabIndex        =   6
      Top             =   4800
      Width           =   825
   End
   Begin VB.CommandButton Digits
      BackColor       =   &H80000009&
      Caption         =   "7"
      Height          =   930
      Index           =   7
      Left            =   0
      MaskColor       =   &H80000009&
      Picture         =   "MathCalc.frx":2492B
      Style           =   1  'Graphical
      TabIndex        =   5
      Top             =   4800
      Width           =   705
   End
   Begin VB.CommandButton Digits
      BackColor       =   &H80000009&
      Caption         =   "6"
      Height          =   930
      Index           =   6
      Left            =   2400
      MaskColor       =   &H80000009&
      Picture         =   "MathCalc.frx":26D0C
      Style           =   1  'Graphical
      TabIndex        =   4
      Top             =   3840
      Width           =   825
   End
   Begin VB.CommandButton Digits
      BackColor       =   &H80000009&
      Caption         =   "5"
      Height          =   930
      Index           =   5
      Left            =   1560
      MaskColor       =   &H80000009&
      Picture         =   "MathCalc.frx":2916E
      Style           =   1  'Graphical
      TabIndex        =   3
      Top             =   3840
      Width           =   825
   End
   Begin VB.CommandButton Digits
      BackColor       =   &H80000009&
      Caption         =   "4"
      Height          =   930
      Index           =   4
      Left            =   720
      MaskColor       =   &H80000009&
      Picture         =   "MathCalc.frx":2B5D8
      Style           =   1  'Graphical
      TabIndex        =   2
      Top             =   3840
      Width           =   825
   End
   Begin VB.CommandButton Digits
      BackColor       =   &H80000009&
      Caption         =   "0"
      Height          =   930
      Index           =   0
      Left            =   2400
      MaskColor       =   &H80000009&
      Picture         =   "MathCalc.frx":2DA84
      Style           =   1  'Graphical
      TabIndex        =   1
      Top             =   4800
      Width           =   810
   End
   Begin VB.Label Display
      Alignment       =   1  'Right Justify
      BorderStyle     =   1  'Fixed Single
      Height          =   735
      Left            =   90
      TabIndex        =   0
      Top             =   120
      Width           =   3645
   End
End
Attribute VB_Name = "MathCalc"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'  ******************************
'  ******************************
'  ** MASTERING VB6            **
'  ** by Evangelos Petroutos   **
'  ** SYBEX, 1998              **
'  ******************************
'  ******************************
Option Explicit
Dim Operand1 As Double, Operand2 As Double
Dim Operator As String
Dim ClearDisplay As Boolean

Private Sub ClearBttn_Click()
    Display.Caption = ""
End Sub

Private Sub Command1_Click()
End
End Sub

Private Sub Command2_Click()
MathCalc.Hide
Calculators.Show
End Sub

Private Sub Digits_Click(Index As Integer)
    If ClearDisplay Then
        Display.Caption = ""
        ClearDisplay = False
    End If
    Display.Caption = Display.Caption + Digits(Index).Caption
End Sub

Private Sub Div_Click()
    Operand1 = Val(Display.Caption)
    Operator = "/"
    Display.Caption = ""
End Sub

Private Sub DotBttn_Click()
    If ClearDisplay Then
        Display.Caption = ""
        ClearDisplay = False
    End If
    If InStr(Display.Caption, ".") Then
        Exit Sub
    Else
        Display.Caption = Display.Caption + "."
    End If
End Sub

Private Sub Equals_Click()
Dim result As Double

On Error GoTo ErrorHandler
    Operand2 = Val(Display.Caption)
    If Operator = "+" Then result = Operand1 + Operand2
    If Operator = "-" Then result = Operand1 - Operand2
    If Operator = "*" Then result = Operand1 * Operand2
    If Operator = "/" And Operand2 <> "0" Then result = Operand1 / Operand2
    Display.Caption = result
    ClearDisplay = True
    Exit Sub
ErrorHandler:
    MsgBox "The operation resulted in the following error" & vbCrLf & Err.Description
    Display.Caption = "ERROR"
    ClearDisplay = True
End Sub

Private Sub Minus_Click()
    Operand1 = Val(Display.Caption)
    Operator = "-"
    Display.Caption = ""
End Sub

Private Sub Over_Click()
    If Val(Display.Caption) <> 0 Then Display.Caption = 1 / Val(Display.Caption)
End Sub

Private Sub Plus_Click()
    Operand1 = Val(Display.Caption)
    Operator = "+"
    Display.Caption = ""
End Sub

Private Sub PlusMinus_Click()
    Display.Caption = -Val(Display.Caption)
End Sub

Private Sub Times_Click()
    Operand1 = Val(Display.Caption)
    Operator = "*"
    Display.Caption = ""
End Sub

corner
© 1996-2008. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Publisher: Lars Hagelin.
bootstrapLabs Logo A bootstrapLabs project.