VB计算器程序 大家帮忙改一下

来源:百度知道 编辑:UC知道 时间:2024/06/06 09:53:19
乘除好像问题比较严重 不会改。。。大家帮下忙咯
Dim Data_One As Long
Dim Data_Two As Long
Dim Data_Three As Long
Dim Data_Four As Long
Dim operator As String

Private Sub Command1_Click(Index As Integer)
Text1.Text = Text1.Text & Index
End Sub
Private Sub Command2_Click()
Data_One = Val(Text1.Text)
Text1.Text = ""
End Sub

Private Sub Command3_Click()
If Text1.Text = "" Then
Text1.Text = Data_One
Else
Text1.Text = Data_One + Val(Text1.Text)
End If

If Text1.Text = "" Then
Text1.Text = Data_Two
Else
Text1.Text = Data_Two - Val(Text1.Text)
End If

If Text1.Text = "" Then
Text1.Text = Data_Three
Text1.Text = Data_Three * Val(Text1.Text)
End If

If Text1.Text = "" Then
Text1.Text = Data_Four
Else
Text1.Text = Data_Four / Val(Text1.Text)
End If

End Sub

Private S

怎么能用Long呢
要用至少也要用Single嘛

Private Data As Double
Private lOperation As Long
Private fClear As Boolean

Private Sub Command1_Click(Index As Integer)
If fClear = True Then Text1.Text = "": fClear = False
Text1.Text = Text1.Text & Index
End Sub

Private Sub Command2_Click()
If fClear = False Then
Select Case lOperation
Case 0
Case 1: Text1.Text = Data + Val(Text1.Text)
Case 2: Text1.Text = Data - Val(Text1.Text)
Case 3: Text1.Text = Data * Val(Text1.Text)
Case 4: Text1.Text = Data / Val(Text1.Text)
End Select
End If
Data = Val(Text1.Text)
fClear = True
lOperation = 1
End Sub

Private Sub Command3_Click()
If fClear = False Then
Select Case lOperation
Case 0
Case 1: Text1.Text = Data + Val(Text1.Text)
Case 2: Text1.Text = Data - Val(Text1.Text)
Case 3: Text1.Text = Data * Val(Text1.Text)
Case 4: Text1.Text =