The code is as follows:
Copy the code code as follows:
/**
*Author: black bird heart
*Version:1.0
*/
Dim IntX As Double 'Global variable used to store calculated values
Dim IntOperation As Double 'Mark operation type
Dim isBegin As Boolean 'Whether the tag has been assigned a value to IntX
Public Sub Clear() 'Clear command function
screen.Caption = ""
End Sub
Public Sub SavaToIntX()
Select Case IntOperation
Case 1 'Addition
If isBegin = False Then
IntX = Val(screen.Caption)
isBegin = True
Else
IntX = IntX + Val(screen.Caption)
End If
Case 2 'Subtraction
If isBegin = False Then
IntX = Val(screen.Caption)
isBegin = True
Else
IntX = IntX - Val(screen.Caption)
End If
Case 3 'Multiplication
If isBegin = False Then
IntX = Val(screen.Caption)
isBegin = True
Else
IntX = IntX * Val(screen.Caption)
'screen.Caption = IntX
End If
Case 4 'Division
If isBegin = False Then
IntX = Val(screen.Caption)
isBegin = True
Else
IntX = IntX / Val(screen.Caption)
End If
End Select
End Sub
Private Sub Command0_Click()
screen.Caption = screen.Caption & 0
End Sub
Private Sub Command1_Click()
screen.Caption = screen.Caption & 1
End Sub
Private Sub Command2_Click()
screen.Caption = screen.Caption & 2
End Sub
Private Sub Command3_Click()
screen.Caption = screen.Caption & 3
End Sub
Private Sub Command4_Click()
screen.Caption = screen.Caption & 4
End Sub
Private Sub Command5_Click()
screen.Caption = screen.Caption & 5
End Sub
Private Sub Command6_Click()
screen.Caption = screen.Caption & 6
End Sub
Private Sub Command7_Click()
screen.Caption = screen.Caption & 7
End Sub
Private Sub Command8_Click()
screen.Caption = screen.Caption & 8
End Sub
Private Sub Command9_Click()
screen.Caption = screen.Caption & 9
End Sub
Private Sub CommandClear_Click() 'Clear command
isBegin = False
IntOperation = 0
IntX = 0
screen.Caption = ""
End Sub
Private Sub CommandEqual_Click() 'Equal sign operation
If IntOperation <> 0 Then 'When there is an operation mark
CallSavaToIntX
IntOperation = 0
isBegin = False
screen.Caption = IntX
End If
End Sub
Private Sub CommandMinus_Click() 'Subtraction operation
If IntOperation <> 0 Then 'When there is an operation mark
CallSavaToIntX
IntOperation = 2
Call Clear
Else
IntOperation = 2
CallSavaToIntX
Call Clear
End If
End Sub
Private Sub CommandMultiple_Click() 'Multiplication operation
If IntOperation <> 0 Then 'When there is an operation mark
CallSavaToIntX
IntOperation = 3
Call Clear
Else
IntOperation = 3
CallSavaToIntX
Call Clear
End If
End Sub
Private Sub CommandPlus_Click() 'Addition operation
If IntOperation <> 0 Then 'When there is an operation mark
CallSavaToIntX
IntOperation = 1
Call Clear
Else
IntOperation = 1
CallSavaToIntX
Call Clear
End If
End Sub
Private Sub CommandSlash_Click() 'Division operation
If IntOperation <> 0 Then 'When there is an operation mark
CallSavaToIntX
IntOperation = 4
Call Clear
Else
IntOperation = 4
CallSavaToIntX
Call Clear
End If
End Sub