Microsoft Office Tutorials and References
In Depth Information
5.4.11 Variable Scope
scope and lifetime of a variable next (but we will not generally include scope prefixes in variable
5.4.11 Variable Scope
Variables and constants have a scope , which indicates where in the program the variable or
constant is recognized (or visible to the code). The scope of a variable or constant can be either
procedure-level (also called local), module-level private, or module-level public. The rules may
seem a bit involved at first, but they do make sense. Procedure-level (local) variables
A local or procedure-level variable or constant is a variable or constant that is declared within a
procedure, as is the case with the variable LocalVar and the constant LocalConstant in
Figure 5-2 . A local variable or constant is not visible outside of the procedure. Thus, for instance,
if we try to run ProcedureB in Figure 5-2 , we will get the error message, "Variable not defined,"
and the name LocalVar will be highlighted.
Figure 5-2. Examples of variable scope
Search JabSto ::

Custom Search