Public Class Form1
Dim sum As Double = 0
Dim operand As String = ""
Dim value1 As Double = 0
Dim value2 As Double = 0
Private Sub btnOne_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOne.Click
txtBox1.Text += "1"
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtBox1.TextChanged
End Sub
Private Sub btnTwo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTwo.Click
txtBox1.Text += "2"
End Sub
Private Sub btnThree_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThree.Click
txtBox1.Text += "3"
End Sub
Private Sub btnFour_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFour.Click
txtBox1.Text += "4"
End Sub
Private Sub btnFive_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFive.Click
txtBox1.Text += "5"
End Sub
Private Sub btnSix_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSix.Click
txtBox1.Text += "6"
End Sub
Private Sub btnSeven_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSeven.Click
txtBox1.Text += "7"
End Sub
Private Sub btnEight_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEight.Click
txtBox1.Text += "8"
End Sub
Private Sub btnNine_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNine.Click
txtBox1.Text += "9"
End Sub
Private Sub btnZero_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnZero.Click
txtBox1.Text += "0"
End Sub
Private Sub btnDot_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDot.Click
Dim btnDot As Boolean = False
If txtBox1.Text.IndexOf(".") >= 0 Then btnDot = True
If btnDot = False Then txtBox1.Text += "."
End Sub
Private Sub btnEquals_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEquals.Click
value2 = Val(txtBox1.Text)
Select Case operand
Case Is = "+"
txtBox1.Text = (value1 + value2).ToString
Case Is = "-"
txtBox1.Text = (value1 - value2).ToString
Case Is = "X"
txtBox1.Text = (value1 * value2).ToString
Case Is = "/"
If value2 <> 0 Then
txtBox1.Text = (value1 / value2).ToString
End If
End Select
End Sub
Private Sub btnPlus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlus.Click
operand = "+"
If checkInput() = True Then value1 = CDbl(txtBox1.Text)
txtBox1.Clear()
End Sub
Private Sub btnMinus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMinus.Click
operand = "-"
If checkInput() = True Then value1 = CDbl(txtBox1.Text)
txtBox1.Clear()
End Sub
Private Sub btnTimes_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTimes.Click
operand = "X"
If checkInput() = True Then value1 = CDbl(txtBox1.Text)
txtBox1.Clear()
End Sub
Private Sub btnDivide_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDivide.Click
operand = "/"
If checkInput() = True Then value1 = CDbl(txtBox1.Text)
txtBox1.Clear()
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
txtBox1.Clear()
sum = 0
End Sub
Private Function checkInput() As Boolean
If IsNumeric(txtBox1.Text) = True And txtBox1.Text <> "" And txtBox1.Text <> Nothing Then
Return True
Else
Return False
End If
End Function
Dim sum As Double = 0
Dim operand As String = ""
Dim value1 As Double = 0
Dim value2 As Double = 0
Private Sub btnOne_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOne.Click
txtBox1.Text += "1"
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtBox1.TextChanged
End Sub
Private Sub btnTwo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTwo.Click
txtBox1.Text += "2"
End Sub
Private Sub btnThree_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThree.Click
txtBox1.Text += "3"
End Sub
Private Sub btnFour_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFour.Click
txtBox1.Text += "4"
End Sub
Private Sub btnFive_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFive.Click
txtBox1.Text += "5"
End Sub
Private Sub btnSix_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSix.Click
txtBox1.Text += "6"
End Sub
Private Sub btnSeven_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSeven.Click
txtBox1.Text += "7"
End Sub
Private Sub btnEight_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEight.Click
txtBox1.Text += "8"
End Sub
Private Sub btnNine_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNine.Click
txtBox1.Text += "9"
End Sub
Private Sub btnZero_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnZero.Click
txtBox1.Text += "0"
End Sub
Private Sub btnDot_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDot.Click
Dim btnDot As Boolean = False
If txtBox1.Text.IndexOf(".") >= 0 Then btnDot = True
If btnDot = False Then txtBox1.Text += "."
End Sub
Private Sub btnEquals_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEquals.Click
value2 = Val(txtBox1.Text)
Select Case operand
Case Is = "+"
txtBox1.Text = (value1 + value2).ToString
Case Is = "-"
txtBox1.Text = (value1 - value2).ToString
Case Is = "X"
txtBox1.Text = (value1 * value2).ToString
Case Is = "/"
If value2 <> 0 Then
txtBox1.Text = (value1 / value2).ToString
End If
End Select
End Sub
Private Sub btnPlus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlus.Click
operand = "+"
If checkInput() = True Then value1 = CDbl(txtBox1.Text)
txtBox1.Clear()
End Sub
Private Sub btnMinus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMinus.Click
operand = "-"
If checkInput() = True Then value1 = CDbl(txtBox1.Text)
txtBox1.Clear()
End Sub
Private Sub btnTimes_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTimes.Click
operand = "X"
If checkInput() = True Then value1 = CDbl(txtBox1.Text)
txtBox1.Clear()
End Sub
Private Sub btnDivide_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDivide.Click
operand = "/"
If checkInput() = True Then value1 = CDbl(txtBox1.Text)
txtBox1.Clear()
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
txtBox1.Clear()
sum = 0
End Sub
Private Function checkInput() As Boolean
If IsNumeric(txtBox1.Text) = True And txtBox1.Text <> "" And txtBox1.Text <> Nothing Then
Return True
Else
Return False
End If
End Function
No comments:
Post a Comment