Simple Calculator
Submitted by agriel_101 on Tuesday, September 17, 2013 - 12:15.
Language
This is a simple calculator written in Visual Basic 6.0.
- Public a1 As Double, a2 As Double, result As Double, degri As Double
- Public a As String, tem As Integer
- Dim countertitle, countertitle1 As Integer
- Dim title, title1 As String
- Dim titledance, titledance1 As String
- Private Sub cmd0_Click()
- txt = txt & 0
- End Sub
- Private Sub cmd1_Click()
- txt = txt & 1
- End Sub
- Private Sub cmd2_Click()
- txt = txt & 2
- End Sub
- Private Sub cmd3_Click()
- txt = txt & 3
- End Sub
- Private Sub cmd4_Click()
- txt = txt & 4
- End Sub
- Private Sub cmd5_Click()
- txt = txt & 5
- End Sub
- Private Sub cmd6_Click()
- txt = txt & 6
- End Sub
- Private Sub cmd7_Click()
- txt = txt & 7
- End Sub
- Private Sub cmd8_Click()
- txt = txt & 8
- End Sub
- Private Sub cmd9_Click()
- txt = txt & 9
- End Sub
- Private Sub cmdback_Click()
- If Val(txt.Caption) <> 0 Then
- txt.Caption = Left$(txt.Caption, Len(txt.Caption) - 1)
- result = Val(txt.Caption)
- End If
- End Sub
- Private Sub cmdclear_Click()
- txt = ""
- cmdpoint.Enabled = True
- End Sub
- Private Sub cmdcot_Click()
- degri = txt.Caption
- a = "cot"
- txt.Caption = ""
- a1 = (degri * 22) / 180 * 7
- result = 1 / Tan(a1)
- If a = "cot" Then
- txt.Caption = result
- End If
- End Sub
- Private Sub cmddiv_Click()
- a1 = txt.Caption
- a = "/"
- txt.Caption = ""
- cmdpoint.Enabled = True
- End Sub
- Private Sub cmdmi_Click()
- a1 = txt.Caption
- a = "-"
- txt.Caption = ""
- cmdpoint.Enabled = True
- End Sub
- Private Sub cmdmul_Click()
- a1 = txt.Caption
- a = "*"
- txt.Caption = ""
- cmdpoint.Enabled = True
- End Sub
- Private Sub cmdnegative_Click()
- txt = "-"
- End Sub
- Private Sub cmdplus_Click()
- a1 = txt.Caption
- a = "+"
- txt.Caption = ""
- cmdpoint.Enabled = True
- End Sub
- Private Sub cmdpoint_Click()
- txt = txt & "."
- cmdpoint.Enabled = False
- End Sub
- Private Sub cmdres_Click()
- a2 = Val(txt.Caption)
- If a = "+" Then result = a1 + a2
- If a = "-" Then result = a1 - a2
- If a = "*" Then result = a1 * a2
- If a = "/" And a2 <> 0 Then result = a1 / a2
- txt.Caption = result
- If a = "/" And a2 = 0 Then txt.Caption = "Can't divided by zero"
- cmdpoint.Enabled = True
- End Sub
- Private Sub cmdsin_Click()
- degri = txt.Caption
- a = "sin"
- txt.Caption = ""
- a1 = (degri * 22) / 180 * 7
- result = Sin(a1)
- If a = "sin" Then
- txt.Caption = result
- End If
- End Sub
- Private Sub cmdtan_Click()
- degri = txt.Caption
- a = "tan"
- txt.Caption = ""
- a1 = (degri * 22) / 180 * 7
- result = Tan(a1)
- If a = "tan" Then
- txt.Caption = result
- End If
- End Sub
- '
- 'Private Sub Form_Load()
- ' Set Skinner1.Forms = Forms
- 'End Sub
- Private Sub dev_Click()
- developer.Show 1
- End Sub
- Private Sub Form_Load()
- title = "Calculator"
- End Sub
- Private Sub pro_Click()
- system.Show 1
- End Sub
- Private Sub Timer1_Timer()
- lblcalc.Left = lblcalc.Left - 100 'code to move the newlife tag in the form
- If lblcalc.Left + lblcalc.Width <= 0 Then
- lblcalc.Left = Picture1.Width
- End If
- titledance = Left(title, countertitle)
- Me.Caption = titledance
- countertitle = countertitle + 1
- If countertitle >= Len(title) + 3 Then
- countertitle = 1
- titledance = ""
- End If
- End Sub
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
Add new comment
- 102 views