Accessing Variables in your project Scope Accessing Variables in your project
Block Level If you dimension your variable in a block of code such as if/then, for/next, or select/case, that variable disappears from memory when the block is done
Procedure Level If you dimension your variable within a subroutine or function, that variable disappears from memory when the procedure is done
Module Level A module is a large block of code identified as a module. Normally it is it’s own file—but not necessarily. If you dimension your variable in a module, but outside of any subroutine or function, that variable disappears from memory when the module is done. …Unless you dimension it Publicly: Public intMyVariable As Integer Module level variables are good in all blocks and procedures of the Module
Procedure Scope You create your subroutines as Public if you wish to share them between code modules Or private if only that module can use it Private Function myFunction()
Namespace Level Relevant to large projects that may consist of several VB projects that interact.