Public Class Form1
Dim number1 As Decimal
Dim number2 As Decimal
Dim use As Integer
Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click
txtDisplay.Text = txtDisplay.Text & btn1.Text
End Sub
Private Sub btn2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn2.Click
txtDisplay.Text = txtDisplay.Text & btn2.Text
End Sub
Private Sub btn3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn3.Click
txtDisplay.Text = txtDisplay.Text & btn3.Text
End Sub
Private Sub btn4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn4.Click
txtDisplay.Text = txtDisplay.Text & btn4.Text
End Sub
Private Sub btn5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn5.Click
txtDisplay.Text = txtDisplay.Text & btn5.Text
End Sub
Private Sub btn6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn6.Click
txtDisplay.Text = txtDisplay.Text & btn6.Text
End Sub
Private Sub btn7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn7.Click
txtDisplay.Text = txtDisplay.Text & btn7.Text
End Sub
Private Sub btn8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn8.Click
txtDisplay.Text = txtDisplay.Text & btn8.Text
End Sub
Private Sub btn9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn9.Click
txtDisplay.Text = txtDisplay.Text & btn9.Text
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
txtDisplay.Text = " "
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
number1 = number1 + Val(txtDisplay.Text)
use = 1
txtDisplay.Clear()
End Sub
Private Sub btnSubtract_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubtract.Click
number1 = number1 + Val(txtDisplay.Text)
use = 2
txtDisplay.Clear()
End Sub
Private Sub btnMultiply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMultiply.Click
number1 = number1 + Val(txtDisplay.Text)
use = 3
txtDisplay.Clear()
End Sub
Private Sub btnDivide_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDivide.Click
number1 = number1 + Val(txtDisplay.Text)
use = 4
txtDisplay.Clear()
End Sub
Private Sub btnEquals_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEquals.Click
number2 = number2 + Val(txtDisplay.Text)
If use = 1 Then
txtDisplay.Text = number1 + number2
ElseIf use = 2 Then
txtDisplay.Text = number1 - number2
ElseIf use = 3 Then
txtDisplay.Text = number1 * number2
ElseIf use = 4 Then
txtDisplay.Text = number1 / number2
End If
number1 = 0
number2 = 0
use = 0
End Sub
Private Sub btnDeciamal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDeciamal.Click
txtDisplay.Text = txtDisplay.Text & btnDeciamal.Text
End Sub
End Class
Monday, May 2, 2011
Programming Final
Calculator
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment