Dim s, op, op1, op2 As String
Private Sub cmd0_Click()
s = s & cmd0.Caption
txtresult = s
End Sub
Private Sub cmd1_Click()
s = s & cmd1.Caption
txtresult = s
End Sub
Private Sub cmd2_Click()
s = s & cmd2.Caption
txtresult = s
End Sub
Private Sub cmd3_Click()
s = s & cmd3.Caption
txtresult = s
End Sub
Private Sub cmd4_Click()
s = s & cmd4.Caption
txtresult = s
End Sub
Private Sub cmd5_Click()
s = s & cmd5.Caption
txtresult = s
End Sub
Private Sub cmd6_Click()
s = s & cmd6.Caption
txtresult = s
End Sub
Private Sub cmd7_Click()
s = s & cmd7.Caption
txtresult = s
End Sub
Private Sub cmd8_Click()
s = s & cmd8.Caption
txtresult = s
End Sub
Private Sub cmd9_Click()
s = s & cmd9.Caption
txtresult = s
End Sub
Private Sub cmdadd_Click()
op = "+"
op1 = s
s = ""
End Sub
Private Sub cmdback_Click()
s = Left(s, Len(s) - 1)
txtresult = s
End Sub
Private Sub cmdclear_Click()
txtresult = ""
s = ""
End Sub
Private Sub cmddiv_Click()
op = "/"
op1 = s
s = ""
End Sub
Private Sub cmddot_Click()
If InStr(s, ".") Then Exit Sub
s = s & cmddot.Caption
txtresult = s
End Sub
Private Sub cmdequal_Click()
op2 = txtresult
If op = "+" Then
txtresult = Val(op1) + Val(op2)
ElseIf op = "-" Then
txtresult = Val(op1) - Val(op2)
ElseIf op = "*" Then
txtresult = Val(op1) * Val(op2)
ElseIf op = "/" Then
txtresult = Val(op1) / Val(op2)
End If
s = txtresult
End Sub
Private Sub cmdMP_Click()
Static b As Boolean
If b = False Then
s = "-" & s
txtresult = s
b = True
Else
s = Mid(s, 2)
txtresult = s
b = False
End If
End Sub
Private Sub cmdmul_Click()
op = "*"
op1 = s
s = ""
End Sub
Private Sub cmdsub_Click()
op = "-"
op1 = s
s = ""
End Sub
sotvisal -4 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.