新人有问题求解决,我想做一个跟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
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
...全文
相关推荐
VS2013自己做的一个简单加减乘除计算器
windows上基于VS2013的计算器,可以实现加减乘除的功能
易语言高仿Windows计算器
易语言高仿Windows计算器源码,高仿Windows计算器,子程序_加减乘除,子程序_加,子程序_减,子程序_乘,子程序_除,子程序_取正,子程序_取负
一份关于windows不错的资料(附:xp出错提示).doc
一份关于windows不错的资料(附:常见xp出错提示对照表) 一份关于windows不错的资料 A ↑ACCESS.CHM-Windows帮助文件ACCSTAT.EXE-辅助状态指示器ADVAPI32.DLL-高级Win32应用程序接口AHA154X.MPD-SCSI驱动程序AM
C语言编写的计算器代码
这是用C语言编写的计算器源代码,可以借鉴学习一下,有错误的地方请改正
计算机课程设计计算器
计算机课程设计,使用MFC编写的一个计算器小程序。 附有程序设计说明书和所需程序代码


VB基础类
