新人有问题求解决,我想做一个跟windows附带的计算器一样的,老是出错,请各位帮忙看看

wdk8882006 wdk8882006 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我想做一个计算器,但是老出错,输入到第6位的时候就不行了,还有"+","-"等等都不能用,以下是我写的,请各位帮帮忙指出其中的错误,我是新人!多多指教!
Dim firstnum As Double
Dim secondnum As Double
Dim char As Double

Private Sub Command1_Click()
Dim num As Integer
Dim newnum As Integer
num = Val(Text1.Text)
newnum = num * 10 + 1
Text1.Text = newnum

End Sub

Private Sub Command10_Click()
firstnum = Val(Text1.Text)
Text1.Text = 0
char = "+"
End Sub

Private Sub Command11_Click()
firstnum = Val(Text1.Text)
Text1.Text = 0
char = "/"
End Sub

Private Sub Command12_Click()
firstnum = Val(Text1.Text)
Text1.Text = 0
char = "*"
End Sub

Private Sub Command13_Click()
firstnum = Val(Text1.Text)
Text1.Text = 0
char = "-"
End Sub

Private Sub Command14_Click()
Dim result As Double
secondnum = Val(Text1.Text)
If char = "+" Then
result = firstnum + secondnum
If char = "-" Then
result = firstnum - secondnum
If char = "/" Then
result = firstnum / secondnum
If char = "*" Then
result = firstnum * secondnum
End If
Text1.Text = result
End Sub

Private Sub Command2_Click()
Dim num As Integer
Dim newnum As Integer
num = Val(Text1.Text)
newnum = num * 10 + 2
Text1.Text = newnum
End Sub

Private Sub Command3_Click()
Dim num As Integer
Dim newnum As Integer
num = Val(Text1.Text)
newnum = num * 10 + 3
Text1.Text = newnum
End Sub

Private Sub Command4_Click()
Dim num As Integer
Dim newnum As Integer
num = Val(Text1.Text)
newnum = num * 10 + 4
Text1.Text = newnum
End Sub

Private Sub Command5_Click()
Dim num As Integer
Dim newnum As Integer
num = Val(Text1.Text)
newnum = num * 10 + 5
Text1.Text = newnum
End Sub

Private Sub Command6_Click()
Dim num As Integer
Dim newnum As Integer
num = Val(Text1.Text)
newnum = num * 10 + 6
Text1.Text = newnum
End Sub

Private Sub Command7_Click()
Dim num As Integer
Dim newnum As Integer
num = Val(Text1.Text)
newnum = num * 10 + 7
Text1.Text = newnum
End Sub

Private Sub Command8_Click()
Dim num As Integer
Dim newnum As Integer
num = Val(Text1.Text)
newnum = num * 10 + 8
Text1.Text = newnum
End Sub

Private Sub Command9_Click()
Dim num As Integer
Dim newnum As Integer
num = Val(Text1.Text)
newnum = num * 10 + 9
Text1.Text = newnum
End Sub
...全文

相关推荐

评论 2
收藏 已收藏
分享
返回顶部
wdk8882006
VB基础类 7,788 成员 197,583 内容