VB.net作业,用VB做一个简单的计算器.
只要能进行简单的加减剩除运算就可以了,今晚就要交,好急!!!有高手做好了的话请发到我的QQ邮箱Q号421813280,比给分!谢谢啦!!...
只要能进行简单的加减剩除运算就可以了,今晚就要交,好急!!!有高手做好了的话请发到我的QQ邮箱Q号421813280,比给分!谢谢啦!!
展开
展开全部
我用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
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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
有钱就做,
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
挺好的,学习一下
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询