Introduction
Notes on VB Process Learning
A process is a code segment that needs to be executed repeatedly and is the basic unit of a program.
Classification of Processes
- General process: a user-defined process
- Event process: a process that is executed when a system-provided event is triggered
Definition of General Processes
Definition of Sub Procedure
- Definition of a procedure without a return value
1 2 3
| Modifier Sub ProcedureName(ParameterName As TypeIdentifier) ... End Sub
|
Definition of Function Procedure
- Definition of a procedure with a return value
1 2 3 4
| Modifier Function ProcedureName(ParameterName As TypeIdentifier) As ReturnType ... ProcedureName = ReturnValue End Function
|
Definition of Property Procedure
- Definition of a property procedure
1 2 3
| Modifier Property ProcedureName(ParameterName As TypeIdentifier) As ReturnType ... End Property
|
Definition of Event Procedure
- Definition of an event procedure
1 2 3
| Modifier Event ProcedureName(ParameterName As TypeIdentifier) As ReturnType ... End Event
|
Scope of Processes
Public
- Can be used in all modules of the project
1 2 3
| Public Sub ProcedureName(ParameterName As TypeIdentifier) ... End Sub
|
Private
- Can only be used in the current module
1 2 3
| Private Sub ProcedureName(ParameterName As TypeIdentifier) ... End Sub
|
Static
1 2 3
| Modifier Static Sub ProcedureName(ParameterName As TypeIdentifier) ... End Sub
|
Passing Parameters by Value and by Reference
Passing by Reference (Default)
1 2 3
| Modifier Sub ProcedureName(ByRef ParameterName As TypeIdentifier) ... End Sub
|
Passing by Value
1 2 3
| Modifier Sub ProcedureName(ByVal ParameterName As TypeIdentifier) ... End Sub
|
Calling a Procedure
1 2 3 4 5 6 7 8 9 10
| ' If there are no arguments, parentheses can be omitted ProcedureName Call ProcedureName
' If there are arguments, a parameter list needs to be passed ProcedureName Argument Call ProcedureName(Argument)
' When called in this way, arguments are treated as expressions ProcedureName(Argument)
|
Conclusion
References
Bilibili - Jiao Da You