小弟刚学vb,编个计算器程序!可是有个问题!希望各位大侠帮忙!
数字计算完以后,在点1的按钮,就接着连着计算后的数!这怎么解决啊!?
以下是我部分代码
Dim a As Integer
Dim b As Integer
Dim c As String
Dim x As Integer
Private Sub a0_Click(Index As Integer)
If x = 1 Then
Text1.Text = "0"
If Text1.Text = "" Then
Text1.Text = Text1.Text & "0"
Exit Sub
End If
End If
Text1.Text = Text1.Text & "0"
End Sub
Private Sub a1_Click(Index As Integer)
If x = 1 Then
Text1.Text = ""
End If
If x = 1 And Text1.Text = "" Then
Text1.Text = Text1.Text & "1"
End If
Text1.Text = Text1.Text & "1"
End Sub
Private Sub a2_Click(Index As Integer)
If x = 1 Then
Text1.Text = "2"
End If
If Text1.Text <> "" Then
Text1.Text = " "
Text1.Text = Text1.Text & "2"
End If
Text1.Text = Text1.Text & "2"
End Sub
Private Sub a3_Click(Index As Integer)
x = True
Text1.Text = Text1.Text & "3"
End Sub
Private Sub a4_Click(Index As Integer)
Text1.Text = Text1.Text & "4"
End Sub
Private Sub a5_Click(Index As Integer)
Text1.Text = Text1.Text & "5"
End Sub
Private Sub a6_Click(Index As Integer)
Text1.Text = Text1.Text & "6"
End Sub
Private Sub a7_Click(Index As Integer)
Text1.Text = Text1.Text & "7"
End Sub
Private Sub a8_Click(Index As Integer)
Text1.Text = Text1.Text & "8"
End Sub
Private Sub a9_Click(Index As Integer)
Text1.Text = Text1.Text & "9"
End Sub
Private Sub b1_Click(Index As Integer)
a = Val(Text1.Text)
b = 1
Text1.Text = ""
End Sub
Private Sub b2_Click(Index As Integer)
a = Val(Text1.Text)
b = 2
Text1.Text = ""
End Sub
Private Sub b3_Click(Index As Integer)
a = Val(Text1.Text)
b = 3
Text1.Text = ""
End Sub
Private Sub b4_Click(Index As Integer)
a = Val(Text1.Text)
b = 4
Text1.Text = ""
End Sub
Private Sub b5_Click()
Select Case b
Case 1
c = Str(a + Val(Text1.Text))
x = 1
Case 2
c = Str(a - Val(Text1.Text))
Case 3
c = Str(a * Val(Text1.Text))
Case 4
If Text1.Text = "0" Then
MsgBox "除数不能为零!"
Else
Text1.Text = Str(a / Val(Text1.Text))
End If
Case Else
Text1.Text = ""
End Select
Text1.Text = c
End Sub
Private Sub return_Click(Index As Integer)
Text1.Text = "0"
End Sub
Private Sub start_Click(Index As Integer)
End
End Sub
Private Sub Text1_Change()
Text1.Text = Val(Text1.Text)
End Sub