用vb写个简单的计算器!急!

来源:百度知道 编辑:UC知道 时间:2024/05/31 11:53:15
大家帮个忙用vb语言写个简单的计算器吧!大恩不言谢了!

Option Explicit
Dim e As String
Dim f As String
Dim op As String
Dim chk As Integer

Private Sub cmdAC_Click()
e = ""
f = ""
op = ""
txtDisp.Caption = "0"
End Sub

Private Sub cmdEq_Click()
If op = "" Then
e = str(-(Val(e)))
txtDisp.Caption = e
Else
f = str(-(Val(e)))
txtDisp.Caption = f
End If
chk = 1
End Sub

Private Sub cmdNum_Click(Index As Integer)
On Error GoTo eh2
If chk = 1 Then
e = ""
f = ""
op = ""
chk = 0
End If
If op = "" Then
e = str(Val(e & str(Index)))
txtDisp.Caption = e
Else
f = str(Val(f & str(Index)))
txtDisp.Caption = f
End If
Exit Sub
eh2:
txtDisp.Caption = "-E-"
e = ""
f = ""
op = "