永发信息网

vb计算器问题啊

答案:1  悬赏:50  手机版
解决时间 2021-05-24 17:34
  • 提问者网友:战魂
  • 2021-05-24 14:12

Private Sub Command3_Click()
If X = "+" Then
now1 = Val(Text1.Text)

now1 = pre + now1
Text1.Text = now1
End If
End Sub


Private Sub Command4_Click()
pre = Val(Text1.Text)
Text1.Text = ""
X = "+"
怎么实现加法啊

最佳答案
  • 五星知识达人网友:举杯邀酒敬孤独
  • 2021-05-24 14:31

“+,-,*,/”设一个按钮组


Private Sub Command2_Click(Index As Integer)
shu1 = Val(Text1.Text)
fuhao = Command2(Index).Caption
Text1.Text = ""
If fuhao = "+" Then
End If
If fuhao = "-" Then
End If
If fuhao = "*" Then
End If
If fuhao = "\" Then
End If
End Sub


等号的按钮的单击事件:


shu2 = Val(Text1.Text)
    Select Case fuhao
    Case "+"
    Text1.Text = shu1 + shu2
    Case "-"
    Text1.Text = shu1 - shu2
    Case "*"
    Text1.Text = shu1 * shu2
    Case "/"
    If shu2 = 0 Then
    MsgBox "除数不能为0"
    Else
    Text1.Text = shu1 / shu2
    End If
    End Select


差点忘了,要在声明部分:


Dim shu1 As Single
Dim shu2 As Single
Dim fuhao As String

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯