Databases Reference
In-Depth Information
or:
Private Function AddOne(i As Integer) As Integer
The difference is simple: a
Private
procedure can only be called from within the module
in which it is defined, whereas a
Public
procedure can be called from within any module
in the project.
Note that if the
Public
or
Private
keyword is omitted from a procedure declaration,
then the procedure is considered to be
Public
.
11.6 Fully Qualified Procedure Names
When we call a public procedure that lies in another code module, there is a potential
problem with ambiguity, for there may be more than one public procedure with the same
name in another module. VBA will execute the first one it finds, and this may not be the
one we had in mind!
The solution is to use a
qualified procedure
name
, which has the form:
ModuleName.ProcedureName
For instance, if a public procedure named
AddOne
lies in a module named Utilities, then
we can call this procedure using the syntax:
Utilities.AddOne