Private & Public Procedures
The Private or Public keyword determines the scope
of the subroutine or function. If you omit this part
of the declaration, the subroutine or function will
be public by default. Consider the following declaration:
Private Sub calc()
The above procedure can only be called from the module
in which it resides. Now consider the following declaration:
Public Sub calc()
Any procedure from any module in that particular
application call the above procedure.
Variable Declaration
Variables can also have public and private scope.
So far, we've used the Dim statement to declare variables.
Normally, you don't need to specify whether a variable
is declared as public or private. Variables declared
within a subroutine or function are automatically
private and cannot be declared public.
|
All controls are always visible
and public to all code within the application.
|
To make a variable truly global to an entire project,
you must use the Public keyword and place the declaration
in a module's Declaration section.
|