VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Calculator

by Arkajo Majumdar (1 Submission)
Category: Math/Dates
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 7th November 2008
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Calculator

Rate Calculator




Private Sub C1_Click()
If Display.Caption = "" Then
MsgBox "Hey man! Give me something to destroy!", 64 + vbOKOnly, "Mad Guy"
Else: Display.Caption = ""
End If
End Sub

Private Sub C2_Click()
If InStr(Display.Caption, "") Then
Exit Sub
Else: Display.Caption = Display.Caption + "."
End If
End Sub

Private Sub C3_Click()
oper1 = Val(Display.Caption)
oper = "+"
Display.Caption = " "
End Sub

Private Sub C4_Click()
oper1 = Val(Display.Caption)
oper = "-"
Display.Caption = " "
End Sub

Private Sub C5_Click()
oper1 = Val(Display.Caption)
oper = "*"
Display.Caption = " "
End Sub

Private Sub C6_Click()
oper1 = Val(Display.Caption)
oper = "/"
Display.Caption = " "
End Sub

Private Sub C7_Click()
Dim res As Double
oper2 = Val(Display.Caption)
If oper = "+" Then res = oper1 + oper2
If oper = "-" Then res = oper1 - oper2
If oper = "*" Then res = oper1 * oper2
If oper = "/" And oper2 <> "0" Then res = oper1 / oper2
Display.Caption = res
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 Form_Load()

End Sub


Download this snippet    Add to My Saved Code

Calculator Comments

No comments have been posted about Calculator. Why not be the first to post a comment about Calculator.

Post your comment

Subject:
Message:
0/1000 characters