VB.net作业,用VB做一个简单的计算器.

只要能进行简单的加减剩除运算就可以了,今晚就要交,好急!!!有高手做好了的话请发到我的QQ邮箱Q号421813280,比给分!谢谢啦!!... 只要能进行简单的加减剩除运算就可以了,今晚就要交,好急!!!有高手做好了的话请发到我的QQ邮箱Q号421813280,比给分!谢谢啦!! 展开
 我来答
wgf1975
2012-08-11 · TA获得超过799个赞
知道小有建树答主
回答量:981
采纳率:50%
帮助的人:202万
展开全部
我用VB做的你看能不能用
Public b
Public c
Public d
Public e
Public f

Private Sub Command14_Click()
d = ""
If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Exit Sub
'c = Text1.Text
If b = "" Then Exit Sub
If e = "+" Then
d = f + b
Else
If e = "-" Then
d = f - b
Else
If e = "*" Then
d = f * b
Else
If e = "/" Then
If b = 0 Then
MsgBox "被除数不能为零!"
Exit Sub
End If
d = f / b
Else
MsgBox "错误操作!"
End If
End If
End If
End If
Text1.Text = d
b = ""
c = ""
e = ""
End Sub
Private Sub Command15_Click()
Text1.Text = ""
b = ""
c = ""
d = ""
e = ""
f = ""
End Sub
Private Sub Form_Load()
Text1.Text = ""
End Sub
Private Sub Command1_Click()
'判断开头有运算符就清零
If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""
'判断开头有0就禁止输入数字
If Text1.Text = "0" Then
Else
a = 1
'发现运算结果就清零
If d <> "" Then Text1.Text = "": d = ""
Text1.Text = Text1.Text & a
End If
b = Text1.Text '得到当前操作数
End Sub
Private Sub Command2_Click()
If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""
If Text1.Text = "0" Then
Else
a = 2
If d <> "" Then Text1.Text = "": d = ""
Text1.Text = Text1.Text & a
End If
b = Text1.Text
End Sub
Private Sub Command3_Click()
If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""
If Text1.Text = "0" Then
Else
a = 3
If d <> "" Then Text1.Text = "": d = ""
Text1.Text = Text1.Text & a
End If
b = Text1.Text
End Sub
Private Sub Command4_Click()
If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""
If Text1.Text = "0" Then
Else
a = 4
If d <> "" Then Text1.Text = "": d = ""
Text1.Text = Text1.Text & a
End If
b = Text1.Text
End Sub
Private Sub Command5_Click()
If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""
If Text1.Text = "0" Then
Else
a = 5
If d <> "" Then Text1.Text = "": d = ""
Text1.Text = Text1.Text & a
End If
b = Text1.Text
End Sub
Private Sub Command6_Click()
If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""
If Text1.Text = "0" Then
Else
a = 6
If d <> "" Then Text1.Text = "": d = ""
Text1.Text = Text1.Text & a
End If
b = Text1.Text
End Sub
Private Sub Command7_Click()
If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""
If Text1.Text = "0" Then
Else
a = 7
If d <> "" Then Text1.Text = "": d = ""
Text1.Text = Text1.Text & a
End If
b = Text1.Text
End Sub
Private Sub Command8_Click()
If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""
If Text1.Text = "0" Then
Else
a = 8
If d <> "" Then Text1.Text = "": d = ""
Text1.Text = Text1.Text & a
End If
b = Text1.Text
End Sub
Private Sub Command9_Click()
If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""
If Text1.Text = "0" Then
Else
a = 9
If d <> "" Then Text1.Text = "": d = ""
Text1.Text = Text1.Text & a
End If
b = Text1.Text
End Sub
Private Sub Command10_Click()
If b = "" Then Exit Sub
a = "+"
e = "+"
f = b
Text1.Text = ""
Text1.Text = Text1.Text & a
End Sub
Private Sub Command11_Click()
If b = "" Then Exit Sub
f = b
a = "-"
e = "-"
Text1.Text = ""
Text1.Text = Text1.Text & a
End Sub
Private Sub Command12_Click()
If b = "" Then Exit Sub
a = "*"
e = "*"
f = b
Text1.Text = ""
Text1.Text = Text1.Text & a
End Sub
Private Sub Command13_Click()
If b = "" Then Exit Sub
a = "/"
e = "/"
f = b '把操作数1提取出来
Text1.Text = ""
Text1.Text = Text1.Text & a
End Sub
Private Sub Command16_Click()
'判断有运算符就清零
If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""
'判断有零和空值就禁止输入0
'发现运算结果就清零
If d <> "" Then Text1.Text = "": d = ""
If Text1.Text = "0" Then
Else
a = 0
If d <> "" Then Text1.Text = "": d = ""
Text1.Text = Text1.Text & a
b = Text1.Text
End If
End Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
leiyangbdwk
2012-08-11 · TA获得超过3295个赞
知道大有可为答主
回答量:4975
采纳率:12%
帮助的人:4332万
展开全部
有钱就做,
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
z天道无为z
2012-08-11 · TA获得超过123个赞
知道答主
回答量:61
采纳率:50%
帮助的人:22.8万
展开全部
挺好的,学习一下
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 2条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式