新人有问题求解决,我想做一个跟windows附带的计算器一样的,老是出错,请各位帮忙看看
我想做一个计算器,但是老出错,输入到第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