How to Control the Scope of a Variable
Usually, a variable is in scope, or has visibility for reference, in all of the section in which you declare it. It is also possible that a variable's access level can have an effect on its scope. See Scope for more information.
Scope at block or procedure level
To give a variable visibility only in a block, put one of the statements
New between the first and last lines of that block.
For example, you can put
Dim between the lines
End of a loop of type
You can refer to the variable only in the block.
To give a variable visibility only in a procedure, put one of the statements
New in the procedure, but not in a block.
You can refer to the variable only in the procedure, which includes all blocks contained in that procedure.
Scope at module or namespace level