frmCalculator.frm

 VERSION 5.00
Begin VB.Form frmCalculator
   BackColor       =   &H80000012&
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Calculator"
   ClientHeight    =   4530
   ClientLeft      =   150
   ClientTop       =   720
   ClientWidth     =   4860
   Icon            =   "frmCalculator.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4530
   ScaleWidth      =   4860
   StartUpPosition =   3  'Windows Default
   Begin VB.Frame fraCalc
      BackColor       =   &H80000012&
      Caption         =   "Calculator"
      ForeColor       =   &H8000000E&
      Height          =   4095
      Left            =   120
      TabIndex        =   26
      Top             =   120
      Width           =   4575
      Begin VB.CommandButton cmdPi
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   3480
         Picture         =   "frmCalculator.frx":0442
         Style           =   1  'Graphical
         TabIndex        =   19
         Top             =   2400
         UseMaskColor    =   -1  'True
         Width           =   615
      End
      Begin VB.CommandButton cmdSqrt
         Caption         =   "Sqrt"
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   3480
         TabIndex        =   18
         Top             =   1920
         UseMaskColor    =   -1  'True
         Width           =   615
      End
      Begin VB.CommandButton cmdPower
         Caption         =   "^"
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   18
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   3480
         TabIndex        =   17
         Top             =   1440
         UseMaskColor    =   -1  'True
         Width           =   615
      End
      Begin VB.CommandButton cmdBackspace
         Caption         =   "<---"
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   2880
         TabIndex        =   28
         Top             =   3360
         UseMaskColor    =   -1  'True
         Width           =   615
      End
      Begin VB.CommandButton cmdAdd
         Caption         =   "+"
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   2880
         MaskColor       =   &H00404040&
         TabIndex        =   10
         Top             =   2880
         UseMaskColor    =   -1  'True
         Width           =   615
      End
      Begin VB.CommandButton cmdSubtract
         Caption         =   "-"
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   2880
         TabIndex        =   11
         Top             =   2400
         UseMaskColor    =   -1  'True
         Width           =   615
      End
      Begin VB.CommandButton cmdMulti
         Caption         =   "x"
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   2880
         TabIndex        =   12
         Top             =   1920
         UseMaskColor    =   -1  'True
         Width           =   615
      End
      Begin VB.CommandButton cmdDiv
         Caption         =   "/"
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   2880
         TabIndex        =   13
         Top             =   1440
         UseMaskColor    =   -1  'True
         Width           =   615
      End
      Begin VB.CommandButton cmdEquals
         Caption         =   "="
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   1680
         TabIndex        =   16
         Top             =   3360
         UseMaskColor    =   -1  'True
         Width           =   1215
      End
      Begin VB.CommandButton cmdExit
         Caption         =   "&Turn Off"
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   1080
         TabIndex        =   25
         Top             =   3360
         Width           =   615
      End
      Begin VB.CommandButton cmdDec
         Caption         =   "."
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   2280
         MaskColor       =   &H00404040&
         TabIndex        =   14
         Top             =   2880
         UseMaskColor    =   -1  'True
         Width           =   615
      End
      Begin VB.CommandButton cmdNeg
         Caption         =   "-/+"
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   1680
         TabIndex        =   15
         Top             =   2880
         UseMaskColor    =   -1  'True
         Width           =   615
      End
      Begin VB.CommandButton cmdCalcbutton
         Caption         =   "0"
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   0
         Left            =   1080
         TabIndex        =   0
         Top             =   2880
         UseMaskColor    =   -1  'True
         Width           =   615
      End
      Begin VB.CommandButton cmdCalcbutton
         Caption         =   "3"
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   3
         Left            =   2280
         TabIndex        =   3
         Top             =   2400
         UseMaskColor    =   -1  'True
         Width           =   615
      End
      Begin VB.CommandButton cmdCalcbutton
         Caption         =   "2"
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   2
         Left            =   1680
         TabIndex        =   2
         Top             =   2400
         UseMaskColor    =   -1  'True
         Width           =   615
      End
      Begin VB.CommandButton cmdCalcbutton
         Caption         =   "1"
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   1
         Left            =   1080
         TabIndex        =   1
         Top             =   2400
         UseMaskColor    =   -1  'True
         Width           =   615
      End
      Begin VB.CommandButton cmdCalcbutton
         Caption         =   "6"
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   6
         Left            =   2280
         TabIndex        =   6
         Top             =   1920
         UseMaskColor    =   -1  'True
         Width           =   615
      End
      Begin VB.CommandButton cmdCalcbutton
         Caption         =   "5"
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   5
         Left            =   1680
         TabIndex        =   5
         Top             =   1920
         UseMaskColor    =   -1  'True
         Width           =   615
      End
      Begin VB.CommandButton cmdCalcbutton
         Caption         =   "4"
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   4
         Left            =   1080
         TabIndex        =   4
         Top             =   1920
         UseMaskColor    =   -1  'True
         Width           =   615
      End
      Begin VB.CommandButton cmdCalcbutton
         Caption         =   "9"
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   9
         Left            =   2280
         TabIndex        =   9
         Top             =   1440
         UseMaskColor    =   -1  'True
         Width           =   615
      End
      Begin VB.CommandButton cmdCalcbutton
         Caption         =   "8"
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   8
         Left            =   1680
         TabIndex        =   8
         Top             =   1440
         UseMaskColor    =   -1  'True
         Width           =   615
      End
      Begin VB.CommandButton cmdCalcbutton
         Caption         =   "7"
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   7
         Left            =   1080
         TabIndex        =   7
         Top             =   1440
         UseMaskColor    =   -1  'True
         Width           =   615
      End
      Begin VB.CommandButton cmdMemMinus
         Caption         =   "M-"
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   480
         TabIndex        =   22
         Top             =   2400
         Width           =   615
      End
      Begin VB.CommandButton cmdMemPlus
         Caption         =   "M+"
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   480
         TabIndex        =   21
         Top             =   1920
         Width           =   615
      End
      Begin VB.CommandButton cmdMemRecall
         Caption         =   "MR"
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   480
         TabIndex        =   20
         Top             =   1440
         Width           =   615
      End
      Begin VB.CommandButton cmdClearE
         Caption         =   "C/E"
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   480
         TabIndex        =   23
         Top             =   840
         Width           =   615
      End
      Begin VB.CommandButton cmdClear
         Caption         =   "C"
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   3480
         TabIndex        =   24
         Top             =   840
         Width           =   615
      End
      Begin VB.Label lblAnswer
         Alignment       =   1  'Right Justify
         BackColor       =   &H80000009&
         BorderStyle     =   1  'Fixed Single
         Caption         =   "0"
         BeginProperty Font
            Name            =   "MS Sans Serif"
            Size            =   13.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   1200
         TabIndex        =   27
         Top             =   840
         Width           =   2175
      End
   End
   Begin VB.Menu mnuFile
      Caption         =   "&File"
      Begin VB.Menu mnuView
         Caption         =   "Scientific View"
         Shortcut        =   ^V
      End
      Begin VB.Menu mnuExit
         Caption         =   "E&xit"
         Shortcut        =   ^X
      End
   End
   Begin VB.Menu mnuHelp
      Caption         =   "&Help"
      Begin VB.Menu mnuAbout
         Caption         =   "&About"
      End
   End
End
Attribute VB_Name = "frmCalculator"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'Author- Mark Overholt
'Title- Calculator
'Date- 3-10-04
'Purpose- To have a program that alows the user to
'preform simple mathematical functions.
'Disclaimer- This program was created be me alone. All Rights Reserved.
'Email- If you have any Questions or comments, Email me at
'Lunarman55@hotmail.com
'please put calculator questions in the Email description

'========================================================
'                        General Declarations
'========================================================
'These variables will be used throught the form only
'(form Level)
Dim intNumdigit1 As Integer
Dim sngNum1 As Single
Dim sngNum2 As Single
Dim sngAnswer As Single
Dim intOperationclick As Integer
Dim intOperation As Integer
'1 = addition, 2= subtraction, 3= multiplication
'4= division, 5= to the power
Dim intFinish As Integer
Dim intDec As Integer
Dim lngDecdigit As Long
Dim sngMemory As Single
Dim blnOperatorUsed As Boolean
Dim intLength As Integer
Dim sngBackSpace As Single



'=========================================================
'                     cmdCalcbutton_click
'=========================================================
'this LONG line of code makes the number in the answer box
'be whatever number is pressed on the screen.

Private Sub cmdCalcbutton_Click(intIndex As Integer)
Select Case intIndex
    Case "0" 'if is 0 is pressed
    Call zero
   
Case "1" 'if is 1 is pressed
  Call one
Case "2" 'if is 2 is pressed
Call two
Case "3" 'if is 3 is pressed
  Call three

Case "4" 'if is 4 is pressed
  Call four
Case "5" 'if is 5 is pressed
  Call five
Case "6" 'if is 6 is pressed
  Call six
Case "7" 'if is 7 is pressed
  Call seven
Case "8" 'if is 8 is pressed
  Call eight
Case "9" 'if is 9 is pressed
  Call nine
End Select


End Sub
'========================================================
'                      cmdsubtract_Click
'========================================================
Private Sub cmdSubtract_Click()
If intOperationclick = 1 Then 'if this is the first operation
sngNum1 = lblAnswer.Caption 'first number becomes number on screen
lblAnswer.Caption = "0" 'changes screen to 0
intOperation = 2 'changes operation to subtraction.
intNumdigit1 = 1 'sets the digit number back to 1
End If
If intOperationclick > 1 Then ' if this is not the first operation in a series
    sngNum2 = lblAnswer.Caption 'second integer becomes screen
    'decides what operation was pressed previously, then
    'preforms it and displays it
    If intOperation = 1 Then
        sngNum1 = sngNum1 + sngNum2
        lblAnswer.Caption = sngNum1
    End If
    If intOperation = 2 Then
        sngNum1 = sngNum1 - sngNum2
        lblAnswer.Caption = sngNum1
    End If
    If intOperation = 3 Then
        sngNum1 = sngNum1 * sngNum2
        lblAnswer.Caption = sngNum1
    End If
    If intOperation = 4 Then
        sngNum1 = sngNum1 / sngNum2
        lblAnswer.Caption = sngNum1
    End If
    If intOperation = 5 Then
        sngNum1 = sngNum1 ^ sngNum2
        lblAnswer.Caption = sngNum1
    End If
    intOperation = 2 'sets operation to subtraction
    intNumdigit1 = 1 ' sets number digit back to one
   
End If
intOperationclick = intOperation + 1 'adds to the number of operations clicked
intDec = 0
lngDecdigit = 1



End Sub


'========================================================
'                      cmdClear_Click
'========================================================
Private Sub cmdClear_Click() 'sets all values back to original and clear lblanswer
lblAnswer.Caption = "0"
intNumdigit1 = 1
intOperationclick = 1
intFinish = 1
intDec = 0
lngDecdigit = 1
End Sub
'========================================================
'                      cmdClearE_Click
'========================================================
'clears lblanswer and changes decimal and digit value to origianl
'all previous values stay the same
Private Sub cmdClearE_Click()

lblAnswer.Caption = "0"
intDec = 0
lngDecdigit = 1
End Sub
'========================================================
'                      cmdDec_Click
'========================================================
'makes numbers here after a decimal value
Private Sub cmdDec_Click()
intDec = 1
End Sub

'========================================================
'                      cmdequals_Click
'========================================================
Private Sub cmdEquals_Click()
sngNum2 = lblAnswer.Caption 'makes the lblanswer the second integer
'decides what operation based on previous clicks then preforms it and shows it
If intOperation = 1 Then
    sngAnswer = sngNum1 + sngNum2
    lblAnswer.Caption = sngAnswer
End If
If intOperation = 2 Then
    sngAnswer = sngNum1 - sngNum2
    lblAnswer.Caption = sngAnswer
End If
If intOperation = 3 Then
    sngAnswer = sngNum1 * sngNum2
    lblAnswer.Caption = sngAnswer
End If
If intOperation = 4 Then
    sngAnswer = sngNum1 / sngNum2
    lblAnswer.Caption = sngAnswer
End If
If intOperation = 5 Then
    sngAnswer = sngNum1 ^ sngNum2
    lblAnswer.Caption = sngAnswer
End If
intNumdigit1 = 1
intDec = 0
lngDecdigit = 1

intOperationclick = 1
End Sub
'========================================================
'                      cmdExit_Click
'========================================================
'unloads all current forms
Private Sub cmdExit_Click()
Unload frmCalculator
Unload frmAbout

End Sub
'========================================================
'                      cmdMemMinus_Click
'========================================================
'changes to memory variable to 0
Private Sub cmdMemMinus_Click()
sngMemory = 0
End Sub
'========================================================
'                      cmdMemPlus_Click
'========================================================
'makes memory variable the screen and clears the screen
Private Sub cmdMemPlus_Click()
sngMemory = lblAnswer.Caption
lblAnswer.Caption = 0
End Sub
'========================================================
'                      cmdMemRecall_Click
'========================================================
'puts memory number on the screen
Private Sub cmdMemRecall_Click()
lblAnswer.Caption = sngMemory
intFinish = 0
End Sub

'========================================================
'                      cmdNeg_Click
'========================================================
'takes the number on screen and subtracts 2 of that number to make it a different sign.
Private Sub cmdNeg_Click()
lblAnswer.Caption = (lblAnswer.Caption - (lblAnswer.Caption * 2))
End Sub


'========================================================
'                      cmdPi_Click
'========================================================
'displays Pi on the screen(8 digits only)
Private Sub cmdPi_Click()
lblAnswer.Caption = 3.1415623
End Sub

'========================================================
'                      cmdPower_Click
'========================================================


Private Sub cmdPower_Click()
If intOperationclick = 1 Then 'if this is the first operation
sngNum1 = lblAnswer.Caption 'first number becomes number on screen
lblAnswer.Caption = "0" 'changes screen to 0
intOperation = 5 'changes operation to the power of.
intNumdigit1 = 1 'sets the digit number back to 1
End If
If intOperationclick > 1 Then ' if this is not the first operation in a series
    sngNum2 = lblAnswer.Caption 'second integer becomes screen
    'decides what operation was pressed previously, then
    'preforms it and displays it
    If intOperation = 1 Then
        sngNum1 = sngNum1 + sngNum2
        lblAnswer.Caption = sngNum1
    End If
    If intOperation = 2 Then
        sngNum1 = sngNum1 - sngNum2
        lblAnswer.Caption = sngNum1
    End If
    If intOperation = 3 Then
        sngNum1 = sngNum1 * sngNum2
        lblAnswer.Caption = sngNum1
    End If
    If intOperation = 4 Then
        sngNum1 = sngNum1 / sngNum2
        lblAnswer.Caption = sngNum1
    End If
    If intOperation = 5 Then
        sngNum1 = sngNum1 ^ sngNum2
        lblAnswer.Caption = sngNum1
    End If
    intOperation = 5 'sets operation to the power of
    intNumdigit1 = 1 ' sets number digit back to one
   
End If
intOperationclick = intOperation + 1 'adds to the number of operations clicked
intDec = 0
lngDecdigit = 1


End Sub
'========================================================
'                      cmdSqrt_Click
'========================================================
'takes the sqaure root of a number(^.5)
Private Sub cmdSqrt_Click()
lblAnswer.Caption = lblAnswer.Caption ^ (0.5)
blnOperatorUsed = True

End Sub



Private Sub cmdBackspace_Click()
    sngBackSpace = CSng(lblAnswer.Caption)
If intNumdigit1 > 2 Then
    intLength = intNumdigit1 - 2
    sngBackSpace = Left(sngBackSpace, intLength)
    lblAnswer.Caption = sngBackSpace
    intNumdigit1 = intNumdigit1 - 1
ElseIf intNumdigit1 = 2 Then
    lblAnswer.Caption = 0
    intNumdigit1 = intNumdigit1 - 1
End If



End Sub

'========================================================
'                      Form_Keypress
'========================================================

'takes what number is pressed on the keyboard
'clicks the correspondins button on the screen
Private Sub Form_KeyPress(KeyAscii As Integer)
Dim strKey As String
    strKey = Chr$(KeyAscii)
   
    Select Case strKey
        Case "0"
            cmdCalcbutton(0).SetFocus
            cmdCalcbutton_Click 0
        Case "1"
            cmdCalcbutton(1).SetFocus
            cmdCalcbutton_Click 1
        Case "2"
            cmdCalcbutton(2).SetFocus
            cmdCalcbutton_Click 2
        Case "3"
            cmdCalcbutton(3).SetFocus
            cmdCalcbutton_Click 3
        Case "4"
            cmdCalcbutton(4).SetFocus
            cmdCalcbutton_Click 4
        Case "5"
            cmdCalcbutton(5).SetFocus
            cmdCalcbutton_Click 5
        Case "6"
            cmdCalcbutton(6).SetFocus
            cmdCalcbutton_Click 6
        Case "7"
            cmdCalcbutton(7).SetFocus
            cmdCalcbutton_Click 7
        Case "8"
            cmdCalcbutton(8).SetFocus
            cmdCalcbutton_Click 8
        Case "9"
            cmdCalcbutton(9).SetFocus
            cmdCalcbutton_Click 9
        Case "+"
            cmdAdd.SetFocus
            cmdAdd_Click
        Case "-"
            cmdSubtract.SetFocus
            cmdSubtract_Click
        Case "*"
            cmdMulti.SetFocus
            cmdMulti_Click
        Case "/"
            cmdDiv.SetFocus
            cmdDiv_Click
        Case "."
            cmdDec.SetFocus
            cmdDec_Click
           
           
       
           
        End Select
       
End Sub

'========================================================
'                     form_load
'========================================================
Private Sub Form_Load()
intOperationclick = 1
'makes form centered
frmCalculator.Top = (Screen.Height - frmCalculator.Height) / 2
frmCalculator.Left = (Screen.Width - frmCalculator.Width) / 2
'makes comlex operation invisble
cmdPower.Visible = False
cmdSqrt.Visible = False
cmdPi.Visible = False
cmdMemMinus.Visible = False
cmdMemPlus.Visible = False
cmdMemRecall.Visible = False
End Sub
'========================================================
'                      cmdadd_Click
'========================================================
Private Sub cmdAdd_Click()
If intOperationclick = 1 Then 'if this is the first operation
sngNum1 = lblAnswer.Caption 'first number becomes number on screen
lblAnswer.Caption = "0" 'changes screen to 0
intOperation = 1 'changes operation to addition.
intNumdigit1 = 1 'sets the digit number back to 1
End If
If intOperationclick > 1 Then ' if this is not the first operation in a series
    sngNum2 = lblAnswer.Caption 'second integer becomes screen
    'decides what operation was pressed previously, then
    'preforms it and displays it
    If intOperation = 1 Then
        sngNum1 = sngNum1 + sngNum2
        lblAnswer.Caption = sngNum1
    End If
    If intOperation = 2 Then
        sngNum1 = sngNum1 - sngNum2
        lblAnswer.Caption = sngNum1
    End If
    If intOperation = 3 Then
        sngNum1 = sngNum1 * sngNum2
        lblAnswer.Caption = sngNum1
    End If
    If intOperation = 4 Then
        sngNum1 = sngNum1 / sngNum2
        lblAnswer.Caption = sngNum1
    End If
    If intOperation = 5 Then
        sngNum1 = sngNum1 ^ sngNum2
        lblAnswer.Caption = sngNum1
    End If
    intOperation = 1 'sets operation to addition
    intNumdigit1 = 1 ' sets number digit back to one
   
End If
intOperationclick = intOperation + 1 'adds to the number of operations clicked
intDec = 0
lngDecdigit = 1

End Sub
'========================================================
'                      cmddiv_Click
'========================================================
Private Sub cmdDiv_Click()
If intOperationclick = 1 Then 'if this is the first operation
sngNum1 = lblAnswer.Caption 'first number becomes number on screen
lblAnswer.Caption = "0" 'changes screen to 0
intOperation = 4 'changes operation to division.
intNumdigit1 = 1 'sets the digit number back to 1
End If
If intOperationclick > 1 Then ' if this is not the first operation in a series
    sngNum2 = lblAnswer.Caption 'second integer becomes screen
    'decides what operation was pressed previously, then
    'preforms it and displays it
    If intOperation = 1 Then
        sngNum1 = sngNum1 + sngNum2
        lblAnswer.Caption = sngNum1
    End If
    If intOperation = 2 Then
        sngNum1 = sngNum1 - sngNum2
        lblAnswer.Caption = sngNum1
    End If
    If intOperation = 3 Then
        sngNum1 = sngNum1 * sngNum2
        lblAnswer.Caption = sngNum1
    End If
    If intOperation = 4 Then
        sngNum1 = sngNum1 / sngNum2
        lblAnswer.Caption = sngNum1
    End If
    If intOperation = 5 Then
        sngNum1 = sngNum1 ^ sngNum2
        lblAnswer.Caption = sngNum1
    End If
    intOperation = 4 'sets operation to division
    intNumdigit1 = 1 ' sets number digit back to one
   
End If
intOperationclick = intOperation + 1 'adds to the number of operations clicked
intDec = 0
lngDecdigit = 1

End Sub



'========================================================
'                      cmdmulti_Click
'========================================================
Private Sub cmdMulti_Click()
If intOperationclick = 1 Then 'if this is the first operation
sngNum1 = lblAnswer.Caption 'first number becomes number on screen
lblAnswer.Caption = "0" 'changes screen to 0
intOperation = 3 'changes operation to multiplication.
intNumdigit1 = 1 'sets the digit number back to 1
End If
If intOperationclick > 1 Then ' if this is not the first operation in a series
    sngNum2 = lblAnswer.Caption 'second integer becomes screen
    'decides what operation was pressed previously, then
    'preforms it and displays it
    If intOperation = 1 Then
        sngNum1 = sngNum1 + sngNum2
        lblAnswer.Caption = sngNum1
    End If
    If intOperation = 2 Then
        sngNum1 = sngNum1 - sngNum2
        lblAnswer.Caption = sngNum1
    End If
    If intOperation = 3 Then
        sngNum1 = sngNum1 * sngNum2
        lblAnswer.Caption = sngNum1
    End If
    If intOperation = 4 Then
        sngNum1 = sngNum1 / sngNum2
        lblAnswer.Caption = sngNum1
    End If
    If intOperation = 5 Then
        sngNum1 = sngNum1 ^ sngNum2
        lblAnswer.Caption = sngNum1
    End If
    intOperation = 3 'sets operation to multiplication
    intNumdigit1 = 1 ' sets number digit back to one
   
End If
intOperationclick = intOperation + 1 'adds to the number of operations clicked
intDec = 0
lngDecdigit = 1

End Sub





'========================================================
'                      Form_Unload_Click
'========================================================
Private Sub Form_Unload(Cancel As Integer)
    End
End Sub
'========================================================
'                      mnuAbout_Click
'========================================================
Private Sub mnuAbout_Click()
frmAbout.Show

End Sub
'========================================================
'                      mnuExit_Click
'========================================================
Private Sub mnuExit_Click()
Unload frmCalculator
Unload frmAbout

End Sub
'========================================================
'                        mnuView_click
'========================================================

Private Sub mnuView_Click()
Select Case mnuView.Checked
Case True
    mnuView.Checked = False
Case False
    mnuView.Checked = True
End Select
If mnuView.Checked = True Then
   cmdPower.Visible = True
    cmdSqrt.Visible = True
    cmdPi.Visible = True
    cmdMemMinus.Visible = True
    cmdMemPlus.Visible = True
    cmdMemRecall.Visible = True
End If
If mnuView.Checked = False Then
    cmdPower.Visible = False
    cmdSqrt.Visible = False
    cmdPi.Visible = False
    cmdMemMinus.Visible = False
    cmdMemPlus.Visible = False
    cmdMemRecall.Visible = False
End If
End Sub
'========================================================
'                        zero
'========================================================
Private Sub zero()
If blnOperatorUsed = True Then
        lblAnswer.Caption = 0
    End If
   
   If intDec = 0 Then 'check to see if its a decimal
        If intFinish = 1 Then 'checks to see if you computation is completed
    intFinish = 0
    sngNum1 = 0
    sngNum2 = 0
    lblAnswer.Caption = "0"
End If

If intNumdigit1 = 0 Then 'if the digit variable = 0, change it to one
intNumdigit1 = 1
End If
If intOperationclick = 1 Then 'check to see if this is the first set of operation.
' if this is the first digit that you have pressed, just make
'the answer 0
If intNumdigit1 = 1 Then
    lblAnswer.Caption = 0
End If
'if this is not the first number clicked, take the current answer
'and multiply if by ten(That just adds a zero to the end).
If intNumdigit1 >= 2 Then
    lblAnswer.Caption = (lblAnswer.Caption * 10)
End If
End If
If intOperationclick > 1 Then 'checks to see if this is not the first set of operations

'check to see if this is the first set of operation.
' if this is the first digit that you have pressed, just make
'the answer 0
If intNumdigit1 = 1 Then
lblAnswer.Caption = "0"
    lblAnswer.Caption = lblAnswer.Caption
End If
If intNumdigit1 >= 2 Then
    lblAnswer.Caption = (lblAnswer.Caption * 10)
End If
End If
'makes the numbers digits + 1
intNumdigit1 = intNumdigit1 + 1

End If
'if the number is a decimal
If intDec = 1 Then
    If lngDecdigit = 0 Then
        lngDecdigit = 1
    End If
lblAnswer.Caption = lblAnswer.Caption + (0 / lngDecdigit)
lngDecdigit = lngDecdigit * 10

End If
'all commands are the same for every othern number
'except it just adds the index after multiply by ten.
blnOperatorUsed = False

End Sub
'========================================================
'                        one
'========================================================
Private Sub one()
If blnOperatorUsed = True Then
        lblAnswer.Caption = 0
    End If
If intDec = 0 Then
If intFinish = 1 Then
    intFinish = 0
    sngNum1 = 0
    sngNum2 = 0
    lblAnswer.Caption = "0"
End If
If intNumdigit1 = 0 Then
intNumdigit1 = 1
End If

If intOperationclick = 1 Then
If intNumdigit1 = 1 Then
    lblAnswer.Caption = lblAnswer.Caption + 1
End If
If intNumdigit1 >= 2 Then
    lblAnswer.Caption = (lblAnswer.Caption * 10) + 1
End If
End If
If intOperationclick > 1 Then

If intNumdigit1 = 1 Then
lblAnswer.Caption = "0"
    lblAnswer.Caption = lblAnswer.Caption + 1
End If
If intNumdigit1 >= 2 Then
    lblAnswer.Caption = (lblAnswer.Caption * 10) + 1
End If
End If


intNumdigit1 = intNumdigit1 + 1
End If
If intDec = 1 Then
    If lngDecdigit = 0 Then
        lngDecdigit = 1
    End If
lblAnswer.Caption = lblAnswer.Caption + (0.1 / lngDecdigit)
lngDecdigit = lngDecdigit * 10

End If
blnOperatorUsed = False
End Sub
'========================================================
'                        two
'========================================================
Private Sub two()
If blnOperatorUsed = True Then
        lblAnswer.Caption = 0
    End If
If intDec = 0 Then

If intFinish = 1 Then
    intFinish = 0
    sngNum1 = 0
    sngNum2 = 0
    lblAnswer.Caption = "0"
End If
If intNumdigit1 = 0 Then
intNumdigit1 = 1
End If
If intOperationclick = 1 Then
If intNumdigit1 = 1 Then
    lblAnswer.Caption = lblAnswer.Caption + 2
End If
If intNumdigit1 >= 2 Then
    lblAnswer.Caption = (lblAnswer.Caption * 10) + 2
End If
End If
If intOperationclick > 1 Then

If intNumdigit1 = 1 Then
lblAnswer.Caption = "0"
    lblAnswer.Caption = lblAnswer.Caption + 2
End If
If intNumdigit1 >= 2 Then
    lblAnswer.Caption = (lblAnswer.Caption * 10) + 2
End If
End If


intNumdigit1 = intNumdigit1 + 1
End If
If intDec = 1 Then
    If lngDecdigit = 0 Then
        lngDecdigit = 1
    End If
lblAnswer.Caption = lblAnswer.Caption + (0.2 / lngDecdigit)
lngDecdigit = lngDecdigit * 10

End If
blnOperatorUsed = False
End Sub
'========================================================
'                        three
'========================================================
Private Sub three()
If blnOperatorUsed = True Then
        lblAnswer.Caption = 0
    End If
If intDec = 0 Then

If intFinish = 1 Then
    intFinish = 0
    sngNum1 = 0
    sngNum2 = 0
    lblAnswer.Caption = "0"
End If
If intNumdigit1 = 0 Then
intNumdigit1 = 1
End If
If intOperationclick = 1 Then
If intNumdigit1 = 1 Then
    lblAnswer.Caption = 3
End If
If intNumdigit1 >= 2 Then
    lblAnswer.Caption = (lblAnswer.Caption * 10) + 3
End If
End If
If intOperationclick > 1 Then
If intNumdigit1 = 1 Then
lblAnswer.Caption = "0"

    lblAnswer.Caption = 3
End If

If intNumdigit1 >= 2 Then
    lblAnswer.Caption = (lblAnswer.Caption * 10) + 3
End If
End If


intNumdigit1 = intNumdigit1 + 1
End If
If intDec = 1 Then
    If lngDecdigit = 0 Then
        lngDecdigit = 1
    End If
lblAnswer.Caption = lblAnswer.Caption + (0.3 / lngDecdigit)
lngDecdigit = lngDecdigit * 10

End If
blnOperatorUsed = False
End Sub
'========================================================
'                        four
'========================================================
Private Sub four()
If blnOperatorUsed = True Then
        lblAnswer.Caption = 0
    End If
If intDec = 0 Then

If intFinish = 1 Then
    intFinish = 0
    sngNum1 = 0
    sngNum2 = 0
    lblAnswer.Caption = "0"
End If
If intNumdigit1 = 0 Then
intNumdigit1 = 1
End If
If intOperationclick = 1 Then
If intNumdigit1 = 1 Then
    lblAnswer.Caption = lblAnswer.Caption & 4
End If
If intNumdigit1 >= 2 Then
    lblAnswer.Caption = (lblAnswer.Caption * 10) + 4
End If
End If
If intOperationclick > 1 Then

If intNumdigit1 = 1 Then
lblAnswer.Caption = "0"
    lblAnswer.Caption = lblAnswer.Caption + 4
End If
If intNumdigit1 >= 2 Then
    lblAnswer.Caption = (lblAnswer.Caption * 10) + 4
End If
End If

intNumdigit1 = intNumdigit1 + 1
End If
If intDec = 1 Then
    If lngDecdigit = 0 Then
        lngDecdigit = 1
    End If
lblAnswer.Caption = lblAnswer.Caption + (0.4 / lngDecdigit)
lngDecdigit = lngDecdigit * 10

End If
blnOperatorUsed = False
End Sub
'========================================================
'                        five
'========================================================
Private Sub five()
If blnOperatorUsed = True Then
        lblAnswer.Caption = 0
    End If
If intDec = 0 Then
If intFinish = 1 Then
    intFinish = 0
    sngNum1 = 0
    sngNum2 = 0
    lblAnswer.Caption = "0"
End If
If intNumdigit1 = 0 Then
intNumdigit1 = 1
End If
If intOperationclick = 1 Then
If intNumdigit1 = 1 Then
    lblAnswer.Caption = lblAnswer.Caption + 5
End If
If intNumdigit1 >= 2 Then
    lblAnswer.Caption = (lblAnswer.Caption * 10) + 5
End If
End If
If intOperationclick > 1 Then

If intNumdigit1 = 1 Then
lblAnswer.Caption = "0"
    lblAnswer.Caption = lblAnswer.Caption + 5
End If
If intNumdigit1 >= 2 Then
    lblAnswer.Caption = (lblAnswer.Caption * 10) + 5
End If
End If

intNumdigit1 = intNumdigit1 + 1
End If
If intDec = 1 Then
    If lngDecdigit = 0 Then
        lngDecdigit = 1
    End If
lblAnswer.Caption = lblAnswer.Caption + (0.5 / lngDecdigit)
lngDecdigit = lngDecdigit * 10

End If
blnOperatorUsed = False
End Sub
'========================================================
'                        six
'========================================================
Private Sub six()
If blnOperatorUsed = True Then
        lblAnswer.Caption = 0
    End If
If intDec = 0 Then

If intFinish = 1 Then
    intFinish = 0
    sngNum1 = 0
    sngNum2 = 0
    lblAnswer.Caption = "0"
End If
If intNumdigit1 = 0 Then
intNumdigit1 = 1
End If
If intOperationclick = 1 Then
If intNumdigit1 = 1 Then
    lblAnswer.Caption = lblAnswer.Caption + 6
End If
If intNumdigit1 >= 2 Then
    lblAnswer.Caption = (lblAnswer.Caption * 10) + 6
End If
End If
If intOperationclick > 1 Then

If intNumdigit1 = 1 Then
lblAnswer.Caption = "0"
    lblAnswer.Caption = lblAnswer.Caption + 6
End If
If intNumdigit1 >= 2 Then
    lblAnswer.Caption = (lblAnswer.Caption * 10) + 6
End If
End If

intNumdigit1 = intNumdigit1 + 1
End If
If intDec = 1 Then
    If lngDecdigit = 0 Then
        lngDecdigit = 1
    End If
lblAnswer.Caption = lblAnswer.Caption + (0.6 / lngDecdigit)
lngDecdigit = lngDecdigit * 10

End If
blnOperatorUsed = False
End Sub
'========================================================
'                        seven
'========================================================
Private Sub seven()
If blnOperatorUsed = True Then
        lblAnswer.Caption = 0
    End If
If intDec = 0 Then

If intFinish = 1 Then
    intFinish = 0
    sngNum1 = 0
    sngNum2 = 0
    lblAnswer.Caption = "0"
End If
If intNumdigit1 = 0 Then
intNumdigit1 = 1
End If
If intOperationclick = 1 Then
If intNumdigit1 = 1 Then
    lblAnswer.Caption = lblAnswer.Caption + 7
End If
If intNumdigit1 >= 2 Then
    lblAnswer.Caption = (lblAnswer.Caption * 10) + 7
End If
End If
If intOperationclick > 1 Then

If intNumdigit1 = 1 Then
lblAnswer.Caption = "0"
    lblAnswer.Caption = lblAnswer.Caption + 7
End If
If intNumdigit1 >= 2 Then
    lblAnswer.Caption = (lblAnswer.Caption * 10) + 7
End If
End If


intNumdigit1 = intNumdigit1 + 1
End If
If intDec = 1 Then
    If lngDecdigit = 0 Then
        lngDecdigit = 1
    End If
lblAnswer.Caption = lblAnswer.Caption + (0.7 / lngDecdigit)
lngDecdigit = lngDecdigit * 10

End If
blnOperatorUsed = False
End Sub
'========================================================
'                        eight
'========================================================
Private Sub eight()
If blnOperatorUsed = True Then
        lblAnswer.Caption = 0
    End If
If intDec = 0 Then

If intFinish = 1 Then
    intFinish = 0
    sngNum1 = 0
    sngNum2 = 0
    lblAnswer.Caption = "0"
End If
If intNumdigit1 = 0 Then
intNumdigit1 = 1
End If
If intOperationclick = 1 Then
If intNumdigit1 = 1 Then
    lblAnswer.Caption = lblAnswer.Caption + 8
End If
If intNumdigit1 >= 2 Then
    lblAnswer.Caption = (lblAnswer.Caption * 10) + 8
End If
End If
If intOperationclick > 1 Then

If intNumdigit1 = 1 Then
lblAnswer.Caption = "0"
    lblAnswer.Caption = lblAnswer.Caption + 8
End If
If intNumdigit1 >= 2 Then
    lblAnswer.Caption = (lblAnswer.Caption * 10) + 8
End If
End If


intNumdigit1 = intNumdigit1 + 1
End If
If intDec = 1 Then
    If lngDecdigit = 0 Then
        lngDecdigit = 1
    End If
lblAnswer.Caption = lblAnswer.Caption + (0.8 / lngDecdigit)
lngDecdigit = lngDecdigit * 10

End If
blnOperatorUsed = False
End Sub
'========================================================
'                        Nine
'========================================================
Private Sub nine()
If blnOperatorUsed = True Then
        lblAnswer.Caption = 0
    End If
If intDec = 0 Then
If intFinish = 1 Then
    intFinish = 0
    sngNum1 = 0
    sngNum2 = 0
    lblAnswer.Caption = "0"
End If
If intNumdigit1 = 0 Then
intNumdigit1 = 1
End If
If intOperationclick = 1 Then
If intNumdigit1 = 1 Then
    lblAnswer.Caption = lblAnswer.Caption + 9
End If
If intNumdigit1 >= 2 Then
    lblAnswer.Caption = (lblAnswer.Caption * 10) + 9
End If
End If
If intOperationclick > 1 Then

If intNumdigit1 = 1 Then
lblAnswer.Caption = "0"
    lblAnswer.Caption = lblAnswer.Caption + 9
End If
If intNumdigit1 >= 2 Then
    lblAnswer.Caption = (lblAnswer.Caption * 10) + 9
End If
End If

intNumdigit1 = intNumdigit1 + 1
End If
If intDec = 1 Then
    If lngDecdigit = 0 Then
        lngDecdigit = 1
    End If
lblAnswer.Caption = lblAnswer.Caption + (0.9 / lngDecdigit)
lngDecdigit = lngDecdigit * 10

End If
blnOperatorUsed = False
End Sub

Project Homepage: