展开全部
Dim a(100) As Double
Dim n&
Dim Plus As Boolean
Dim yunsuan(100) As Integer '------------这里增加
Dim a100 As Double
Private Sub cmd1_Click()
If Plus = True Then
Plus = False
Text1.Text = "1"
Else
Text1.Text = Text1.Text & "1"
End If
End Sub
Private Sub cmd2_Click()
If Plus = True Then
Plus = False
Text1.Text = "2"
Else
Text1.Text = Text1.Text & "2"
End If
End Sub
Private Sub cmd3_Click()
If Plus = True Then
Plus = False
Text1.Text = "3"
Else
Text1.Text = Text1.Text & "3"
End If
End Sub
Private Sub cmd4_Click()
If Plus = True Then
Plus = False
Text1.Text = "4"
Else
Text1.Text = Text1.Text & "4"
End If
End Sub
Private Sub cmd5_Click()
If Plus = True Then
Plus = False
Text1.Text = "5"
Else
Text1.Text = Text1.Text & "5"
End If
End Sub
Private Sub cmd6_Click()
If Plus = True Then
Plus = False
Text1.Text = "6"
Else
Text1.Text = Text1.Text & "6"
End If
End Sub
Private Sub cmd7_Click()
If Plus = True Then
Plus = False
Text1.Text = "7"
Else
Text1.Text = Text1.Text & "7"
End If
End Sub
Private Sub cmd8_Click()
If Plus = True Then
Plus = False
Text1.Text = "8"
Else
Text1.Text = Text1.Text & "8"
End If
End Sub
Private Sub cmd9_Click()
If Plus = True Then
Plus = False
Text1.Text = "9"
Else
Text1.Text = Text1.Text & "9"
End If
End Sub
Private Sub cmd0_Click()
If Plus = True Then
Plus = False
Text1.Text = "0"
Else
Text1.Text = Text1.Text & "0"
End If
End Sub
Private Sub cmdDian_Click()
If Plus = True Then
Plus = False
Text1.Text = "0."
Else
Text1.Text = Text1.Text & "."
End If
End Sub
Private Sub cmdjia_Click()
If Plus = False Then
a(n) = Val(Text1.Text)
yunsuan(n) = 0 '------这是在加号里
n = n + 1
Plus = True
End If
End Sub
Private Sub cmdjian_Click()
If Plus = False Then
a(n) = Val(Text1.Text)
yunsuan(n) = 1 '------这是在减号里
n = n + 1
Plus = True
End If
End Sub
Private Sub cmdcheng_Click()
If Plus = False Then
a(n) = Val(Text1.Text)
yunsuan(n) = 2 '------这是在乘号里
n = n + 1
Plus = True
End If
End Sub
Private Sub cmdchu_Click()
If Plus = False Then
a(n) = Val(Text1.Text)
yunsuan(n) = 3 '------这是在除号里
n = n + 1
Plus = True
End If
End Sub
Private Sub cmdDengyu_Click() '-------这是等于号
If Plus = False Then
a(n) = Val(Text1.Text)
End If
a(100) = a(0) '初始为a(0)
For i = 1 To 99
If yunsuan(i - 1) = 0 Then '------如果是加
a(100) = a(100) + a(i)
ElseIf yunsuan(i - 1) = 1 Then '----------如果是减
a(100) = a(100) - a(i)
ElseIf yunsuan(i - 1) = 2 Then '-----xxx
a(100) = a(100) * a(i)
ElseIf yunsuan(i - 1) = 3 Then '--------///
a(100) = a(100) / a(i)
End If
Next
Plus = False
Text1.Text = a(100)
n = 0
a100 = a(100)
Erase a
a(0) = a100
Erase yunsuan '--------清理
End Sub
Private Sub Command17_Click()
Text1.Text = ""
Erase a
Erase yunsuan
n = 0
End Sub
Private Sub Form_Load()
Text1.Locked = True
n = 0
Plus = False
End Sub
Private Sub form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 97 Then cmd1_Click
If KeyCode = 98 Then cmd2_Click
If KeyCode = 99 Then cmd3_Click
If KeyCode = 100 Then cmd4_Click
If KeyCode = 101 Then cmd5_Click
If KeyCode = 102 Then cmd6_Click
If KeyCode = 103 Then cmd7_Click
If KeyCode = 104 Then cmd8_Click
If KeyCode = 105 Then cmd9_Click
If KeyCode = 96 Then cmd0_Click
If KeyCode = 110 Then cmdDian_Click
If KeyCode = 109 Then cmdjian_Click
If KeyCode = 13 Then cmdDengyu_Click
If KeyCode = 111 Then cmdchu_Click
If KeyCode = 107 Then cmdjia_Click
If KeyCode = 106 Then cmdcheng_Click
Debug.Print KeyCode, vbKey1
End Sub
Dim n&
Dim Plus As Boolean
Dim yunsuan(100) As Integer '------------这里增加
Dim a100 As Double
Private Sub cmd1_Click()
If Plus = True Then
Plus = False
Text1.Text = "1"
Else
Text1.Text = Text1.Text & "1"
End If
End Sub
Private Sub cmd2_Click()
If Plus = True Then
Plus = False
Text1.Text = "2"
Else
Text1.Text = Text1.Text & "2"
End If
End Sub
Private Sub cmd3_Click()
If Plus = True Then
Plus = False
Text1.Text = "3"
Else
Text1.Text = Text1.Text & "3"
End If
End Sub
Private Sub cmd4_Click()
If Plus = True Then
Plus = False
Text1.Text = "4"
Else
Text1.Text = Text1.Text & "4"
End If
End Sub
Private Sub cmd5_Click()
If Plus = True Then
Plus = False
Text1.Text = "5"
Else
Text1.Text = Text1.Text & "5"
End If
End Sub
Private Sub cmd6_Click()
If Plus = True Then
Plus = False
Text1.Text = "6"
Else
Text1.Text = Text1.Text & "6"
End If
End Sub
Private Sub cmd7_Click()
If Plus = True Then
Plus = False
Text1.Text = "7"
Else
Text1.Text = Text1.Text & "7"
End If
End Sub
Private Sub cmd8_Click()
If Plus = True Then
Plus = False
Text1.Text = "8"
Else
Text1.Text = Text1.Text & "8"
End If
End Sub
Private Sub cmd9_Click()
If Plus = True Then
Plus = False
Text1.Text = "9"
Else
Text1.Text = Text1.Text & "9"
End If
End Sub
Private Sub cmd0_Click()
If Plus = True Then
Plus = False
Text1.Text = "0"
Else
Text1.Text = Text1.Text & "0"
End If
End Sub
Private Sub cmdDian_Click()
If Plus = True Then
Plus = False
Text1.Text = "0."
Else
Text1.Text = Text1.Text & "."
End If
End Sub
Private Sub cmdjia_Click()
If Plus = False Then
a(n) = Val(Text1.Text)
yunsuan(n) = 0 '------这是在加号里
n = n + 1
Plus = True
End If
End Sub
Private Sub cmdjian_Click()
If Plus = False Then
a(n) = Val(Text1.Text)
yunsuan(n) = 1 '------这是在减号里
n = n + 1
Plus = True
End If
End Sub
Private Sub cmdcheng_Click()
If Plus = False Then
a(n) = Val(Text1.Text)
yunsuan(n) = 2 '------这是在乘号里
n = n + 1
Plus = True
End If
End Sub
Private Sub cmdchu_Click()
If Plus = False Then
a(n) = Val(Text1.Text)
yunsuan(n) = 3 '------这是在除号里
n = n + 1
Plus = True
End If
End Sub
Private Sub cmdDengyu_Click() '-------这是等于号
If Plus = False Then
a(n) = Val(Text1.Text)
End If
a(100) = a(0) '初始为a(0)
For i = 1 To 99
If yunsuan(i - 1) = 0 Then '------如果是加
a(100) = a(100) + a(i)
ElseIf yunsuan(i - 1) = 1 Then '----------如果是减
a(100) = a(100) - a(i)
ElseIf yunsuan(i - 1) = 2 Then '-----xxx
a(100) = a(100) * a(i)
ElseIf yunsuan(i - 1) = 3 Then '--------///
a(100) = a(100) / a(i)
End If
Next
Plus = False
Text1.Text = a(100)
n = 0
a100 = a(100)
Erase a
a(0) = a100
Erase yunsuan '--------清理
End Sub
Private Sub Command17_Click()
Text1.Text = ""
Erase a
Erase yunsuan
n = 0
End Sub
Private Sub Form_Load()
Text1.Locked = True
n = 0
Plus = False
End Sub
Private Sub form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 97 Then cmd1_Click
If KeyCode = 98 Then cmd2_Click
If KeyCode = 99 Then cmd3_Click
If KeyCode = 100 Then cmd4_Click
If KeyCode = 101 Then cmd5_Click
If KeyCode = 102 Then cmd6_Click
If KeyCode = 103 Then cmd7_Click
If KeyCode = 104 Then cmd8_Click
If KeyCode = 105 Then cmd9_Click
If KeyCode = 96 Then cmd0_Click
If KeyCode = 110 Then cmdDian_Click
If KeyCode = 109 Then cmdjian_Click
If KeyCode = 13 Then cmdDengyu_Click
If KeyCode = 111 Then cmdchu_Click
If KeyCode = 107 Then cmdjia_Click
If KeyCode = 106 Then cmdcheng_Click
Debug.Print KeyCode, vbKey1
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询