Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class frmCalculator
- Private Sub btnEquals_Click(sender As System.Object, e As System.EventArgs) Handles btnEquals.Click
- Dim num1 As String
- Dim num2 As String
- Dim op As String
- Dim total As Integer 'or dim it to a double if you want decimals
- num1 = txtCal.Text.Split(" ")(0)
- num2 = txtCal.Text.Split(" ")(2)
- op = txtCal.Text.Split(" ")(1)
- Dim i As Double = Convert.ToDouble(num1)
- Dim i2 As Double = Convert.ToDouble(num2)
- If op = "+" Then
- total = i + i2
- txtCal.Text = total
- ElseIf op = "-" Then
- total = i - i2
- txtCal.Text = total
- ElseIf op = "*" Then
- total = i * i2
- txtCal.Text = total
- ElseIf op = "/" Then
- total = i / i2
- txtCal.Text = total
- End If
- End Sub
- Private Sub Button7_Click(sender As System.Object, e As System.EventArgs) Handles Button7.Click
- txtCal.AppendText("1")
- End Sub
- Private Sub Button8_Click(sender As System.Object, e As System.EventArgs) Handles Button8.Click
- txtCal.AppendText("2")
- End Sub
- Private Sub Button9_Click(sender As System.Object, e As System.EventArgs) Handles Button9.Click
- txtCal.AppendText("3")
- End Sub
- Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click
- txtCal.AppendText("4")
- End Sub
- Private Sub Button5_Click(sender As System.Object, e As System.EventArgs) Handles Button5.Click
- txtCal.AppendText("5")
- End Sub
- Private Sub Button6_Click(sender As System.Object, e As System.EventArgs) Handles Button6.Click
- txtCal.AppendText("6")
- End Sub
- Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
- txtCal.AppendText("7")
- End Sub
- Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
- txtCal.AppendText("8")
- End Sub
- Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
- txtCal.AppendText("9")
- End Sub
- Private Sub Button14_Click(sender As System.Object, e As System.EventArgs) Handles Button14.Click
- txtCal.AppendText("0")
- End Sub
- Private Sub Button10_Click(sender As System.Object, e As System.EventArgs) Handles Button10.Click
- txtCal.AppendText(" + ")
- End Sub
- Private Sub Button11_Click(sender As System.Object, e As System.EventArgs) Handles Button11.Click
- txtCal.AppendText(" - ")
- End Sub
- Private Sub Button12_Click(sender As System.Object, e As System.EventArgs) Handles Button12.Click
- txtCal.AppendText(" * ")
- End Sub
- Private Sub Button13_Click(sender As System.Object, e As System.EventArgs) Handles Button13.Click
- txtCal.AppendText(" / ")
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement