please help me to finish this calc.
this calc.'s work, but when i do this < 1 + 1 * 2 > or i should say when using other operations it stops working. here's my code:
Public Class Form1
Dim num1, num2 As Integer
Dim opr As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn0.Click
lbl1.Text = lbl1.Text & "0"
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click
lbl1.Text = lbl1.Text & "1"
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn2.Click
lbl1.Text = lbl1.Text & "2"
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn3.Click
lbl1.Text = lbl1.Text & "3"
End Sub
Private Sub btn4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn4.Click
lbl1.Text = lbl1.Text & "4"
End Sub
Private Sub btn5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn5.Click
lbl1.Text = lbl1.Text & "5"
End Sub
Private Sub btn6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn6.Click
lbl1.Text = lbl1.Text & "6"
End Sub
Private Sub btn7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn7.Click
lbl1.Text = lbl1.Text & "7"
End Sub
Private Sub btn8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn8.Click
lbl1.Text = lbl1.Text & "8"
End Sub
Private Sub btn9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn9.Click
lbl1.Text = lbl1.Text & "9"
End Sub
Private Sub btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnclear.Click
lbl1.Text = ""
End Sub
Private Sub btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadd.Click
num1 = Val(lbl1.Text)
opr = "+"
lbl1.Text = ""
End Sub
Private Sub btnsubtract_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsubtract.Click
num1 = Val(lbl1.Text)
opr = "-"
lbl1.Text = ""
End Sub
Private Sub btnmultiply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnmultiply.Click
num1 = Val(lbl1.Text)
opr = "*"
lbl1.Text = ""
End Sub
Private Sub btndivide_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndivide.Click
num1 = Val(lbl1.Text)
opr = "/"
lbl1.Text = ""
End Sub
Private Sub btnequals_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnequals.Click
num2 = Val(lbl1.Text)
Select Case opr
Case "+" : lbl1.Text = num1 + num2
Case "-" : lbl1.Text = num1 - num2
Case "*" : lbl1.Text = num1 * num2
Case "/" : lbl1.Text = num1 / num2
End Select
End Sub
Private Sub lbl1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbl1.Click
lbl1.Text = ""
End Sub
End Class
No comments:
Post a Comment