夜╮偽誰落幕 发表于 2012-11-5 20:40:22

VB6编写计算器 ,别的都可以,就是 怎么样能使运算符可以重复按多次,请高手指引下

按重复数字行    但是按加减乘除就不行了   请高手指导下
Dim a As Integer
QQ截图20121105204546.pngQQ截图20121105204546.pngQQ截图20121105204615.png
Dim a As Integer
Dim s As String
Private Sub Command1_Click()
Text1.Text = Text1.Text & Command1.Caption
End Sub

Private Sub Command10_Click()
Text1.Text = Text1.Text & Command10.Caption
End Sub

Private Sub Command11_Click()
Text1.Text = ""
End Sub

Private Sub Command12_Click()
On Error Resume Next
If s = "+" Then
Text1.Text = Val(Text1.Text) + a
ElseIf s = "-" Then
Text1.Text = a - Val(Text1.Text)
ElseIf s = "*" Then
Text1.Text = Val(Text1.Text) * a
ElseIf s = "/" Then
Text1.Text = a / Val(Text1.Text)
End If
End Sub

Private Sub Command13_Click()
a = Text1.Text
Text1.Text = ""
s = "+"
End Sub

Private Sub Command14_Click()
a = Text1.Text
Text1.Text = ""
s = "-"
End Sub

Private Sub Command15_Click()
a = Text1.Text
Text1.Text = ""
s = "*"
End Sub

Private Sub Command16_Click()
a = Text1.Text
Text1.Text = ""
s = "/"
End Sub

Private Sub Command2_Click()
Text1.Text = Text1.Text & Command2.Caption
End Sub

Private Sub Command3_Click()
Text1.Text = Text1.Text & Command3.Caption
End Sub

Private Sub Command4_Click()
Text1.Text = Text1.Text & Command4.Caption
End Sub

Private Sub Command5_Click()
Text1.Text = Text1.Text & Command5.Caption
End Sub

Private Sub Command6_Click()
Text1.Text = Text1.Text & Command6.Caption
End Sub

Private Sub Command7_Click()
Text1.Text = Text1.Text & Command7.Caption
End Sub

Private Sub Command8_Click()
Text1.Text = Text1.Text & Command8.Caption
End Sub

Private Sub Command9_Click()
Text1.Text = Text1.Text & Command9.Caption
End Sub

夜╮偽誰落幕 发表于 2012-11-5 20:43:38

Private Sub Command13_Click()
a = Text1.Text      ‘   这个的问题
Text1.Text = ""
s = "+"
End Sub

dakaijixian 发表于 2012-12-11 21:05:07

没看明白,什么问题

AS爱上· 发表于 2013-2-2 13:35:51

加标志位,就可以解决了
页: [1]
查看完整版本: VB6编写计算器 ,别的都可以,就是 怎么样能使运算符可以重复按多次,请高手指引下