Is it possible to define a variable in a block in order to make
it invisible outside that block?
Several responders so far have expressed mild disapproval of the practice.
I disagree. I think it is usually (never say always) good practice to limit
the scope of variables. I avoid the practice in loops, but I do use "for i
as integer = ..." which limits the scope of the loop variable i. The most
useful place for the practice (my opinion) is if-then-else blocks where
processing logic often dictates variables used in the then or else clause but
not in both. By placing Dim statements with complex initializers in such
blocks, some of them may not be executed at all depending on the code
execution path. By placing the Dim's at the top of the sub, you either have
to execute the complex initializers (a possible performance hit) or forego
using some initializers (a loss of language utility for the sake of a
stylistic objection).