0% found this document useful (0 votes)
44 views

Option Compare Database

The document contains code for a basic calculator application. It defines variables to store numeric values and operators, and includes subroutines for each of the numeric buttons, operators, and functions. The subroutines update the display label based on the button clicked by either setting the label text directly or performing calculations and updating the values of variables to be used by the equals button subroutine.

Uploaded by

Anjjjj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

Option Compare Database

The document contains code for a basic calculator application. It defines variables to store numeric values and operators, and includes subroutines for each of the numeric buttons, operators, and functions. The subroutines update the display label based on the button clicked by either setting the label text directly or performing calculations and updating the values of variables to be used by the equals button subroutine.

Uploaded by

Anjjjj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Option Compare Database

Option Explicit

Dim firstnum As Double

Dim secondnum As Double

Dim answer As Double

Dim opera As String

Private Sub btn0_Click()

If lbldisplay.Caption = "0" Then

lbldisplay.Caption = "0"

Else

lbldisplay.Caption = lbldisplay.Caption + "0"

End If

End Sub

Private Sub btn1_Click()

If lbldisplay.Caption = "0" Then

lbldisplay.Caption = "1"

Else

lbldisplay.Caption = lbldisplay.Caption + "1"

End If

End Sub

Private Sub btn2_Click()

If lbldisplay.Caption = "0" Then

lbldisplay.Caption = "2"

Else

lbldisplay.Caption = lbldisplay.Caption + "2"


End If

End Sub

Private Sub btn3_Click()

If lbldisplay.Caption = "0" Then

lbldisplay.Caption = "3"

Else

lbldisplay.Caption = lbldisplay.Caption + "3"

End If

End Sub

Private Sub btn4_Click()

If lbldisplay.Caption = "0" Then

lbldisplay.Caption = "4"

Else

lbldisplay.Caption = lbldisplay.Caption + "4"

End If

End Sub

Private Sub btn5_Click()

If lbldisplay.Caption = "0" Then

lbldisplay.Caption = "5"

Else

lbldisplay.Caption = lbldisplay.Caption + "5"

End If

End Sub

Private Sub btn6_Click()

If lbldisplay.Caption = "0" Then


lbldisplay.Caption = "6"

Else

lbldisplay.Caption = lbldisplay.Caption + "6"

End If

End Sub

Private Sub btn7_Click()

If lbldisplay.Caption = "0" Then

lbldisplay.Caption = "7"

Else

lbldisplay.Caption = lbldisplay.Caption + "7"

End If

End Sub

Private Sub btn8_Click()

If lbldisplay.Caption = "0" Then

lbldisplay.Caption = "8"

Else

lbldisplay.Caption = lbldisplay.Caption + "8"

End If

End Sub

Private Sub btn9_Click()

If lbldisplay.Caption = "0" Then

lbldisplay.Caption = "9"

Else

lbldisplay.Caption = lbldisplay.Caption + "9"

End If

End Sub
Private Sub btnAdd_Click()

firstnum = lbldisplay.Caption

lbldisplay.Caption = ""

opera = "+"

End Sub

Private Sub Btnback_Click()

Dim strText As String

strText = lbldisplay.Caption

strText = Left(strText, Len(strText) - 1)

lbldisplay.Caption = strText

End Sub

Private Sub BtnClear_Click()

lbldisplay.Caption = "0"

End Sub

Private Sub btnCos_Click()

lbldisplay.Caption = Format(Cos(lbldisplay.Caption), "##0.#########")

End Sub

Private Sub btndivide_Click()

firstnum = lbldisplay.Caption

lbldisplay.Caption = ""

opera = "/"

End Sub

Private Sub btnDot_Click()


If InStr(lbldisplay.Caption, ".") = 0 Then

lbldisplay.Caption = lbldisplay.Caption + "."

End If

End Sub

Private Sub btnEquals_Click()

secondnum = lbldisplay.Caption

If opera = "+" Then

answer = firstnum + secondnum

lbldisplay.Caption = answer

ElseIf opera = "-" Then

answer = firstnum - secondnum

lbldisplay.Caption = answer

ElseIf opera = "*" Then

answer = firstnum * secondnum

lbldisplay.Caption = answer

ElseIf opera = "/" Then

answer = firstnum / secondnum

lbldisplay.Caption = answer

ElseIf opera = "Mod" Then

answer = firstnum Mod secondnum

lbldisplay.Caption = answer
End If

End Sub

Private Sub btnMinus_Click()

firstnum = lbldisplay.Caption

lbldisplay.Caption = ""

opera = "-"

End Sub

Private Sub btnMode_Click()

firstnum = lbldisplay.Caption

lbldisplay.Caption = ""

opera = "Mode"

End Sub

Private Sub btnMultiply_Click()

firstnum = lbldisplay.Caption

lbldisplay.Caption = ""

opera = "*"

End Sub

Private Sub btnP_M_Click()

lbldisplay.Caption = -1 * CDbl(lbldisplay.Caption)

End Sub

Private Sub btnSin_Click()

lbldisplay.Caption = Format(Sin(lbldisplay.Caption), "##0.#########")

End Sub
Private Sub btnSq_Click()

lbldisplay.Caption = CDbl(lbldisplay.Caption) ^ 2

End Sub

Private Sub btnTan_Click()

lbldisplay.Caption = Format(Tan(lbldisplay.Caption), "##0.#########")

End Sub

You might also like