Procedure Scope
Also known as Local Variables or Procedure Level.
Procedure level variables are declared inside an individual procedure or function and are not visible outside that subroutine
Procedure level variables can have two flavours either Dim or Static.
The most common way to declare a local variable is to use the Dim statement.
Public Sub Procedure_Name()
Dim slocalvariable As String
End Sub
When the procedure ends the variable is automatically removed and the memory is released.
A procedure level variables can can only be used in the procedure (or function) it is declared in.
Re-Use Variable Names
One of the great advantages of local variables is that we can use the same name in different subroutines without any conflicts.
Public Sub Procedure_One()
Dim slocalvariable As String
End Sub
Public Sub Procedure_Two()
Dim slocalvariable As String
End Sub
Static Variables
A Static Variable is a local variable whose lifetime is the lifetime of the entire module and not the procedure where it is declared.
Public Sub Procedure_Name()
Static slocalvariable As String
End Sub
Not Private, Public or Global
You canot use the Private, Public or Global statements to declare local variables.
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext