Private Public and Procedure Scope

The Private and Public keywords used with procedure definitions have a similar function to that used with variable declarations. Private and Public are used to define the procedure's scope. The Public keyword makes the procedure visible to all other procedures in all modules in the project. The Private keyword ensures that the procedure is visible to other procedures within the same module, but keeps it inaccessible to all other procedures outside the module in which it is defined. The Private and Public keywords are optional, but VBA includes them in predefined event procedures. If Private or Public is omitted, then the procedure is public by default.

Use the Opt i on Pri vate statement ¡n the general declarations section of a module to keep public modules visible only within the project. Omit Opt i on Pri vate if you wish to create reusable procedures that will be available for any project.

Was this article helpful?

0 0
Biorhythm Awareness

Biorhythm Awareness

Who else wants to take advantage of biorhythm awareness to avoid premature death, escape life threatening diseases, eliminate most of your life altering mistakes and banish catastrophic events from your life.

Get My Free Ebook

Post a comment