Globals Vars

DeTonio

New member
Joined
Sep 6, 2012
Messages
1
Programming Experience
10+
I have defined a set of Global Vars in a Module named MyExcelGlobalVars; the Module only declares a handful of variables. And I set a Imports Statement at the top of a second Module named ExcelMakeMePretty where a a number of Public Sub are stored which use the global vars. In someplaces in the ModuleExcelMakeMePretty I can use the global vars without the reference to the Object MyExcelGlobalVars. Is there a rule to follow here?
 
A module is not an object, it is a collection of shared members, similar to a Class where all members are declared Shared. These members are available globally in project within same namespace, only if module is defined in different namespace you need to import or qualify the namespace. They are also subject to type promotion, which means you don't have to qualify the member with the type name, this is valid also if you need to qualify namespace.
A good rule for writing better object oriented code is to avoid Module, unless you specifically need this behaviour.
 
Back
Top