A variable DIM'med inside any sub or function (in any module or form)
is local to that routine only (only known about by the dim'ming routine),
and is destroyed upon exiting that routine.
A variable DIM'med as Private in the general declarations section of
a Form is available only to routines in that form. The variable remains
valid as long as the form is loaded.
A variable DIM'med as Public in the general declarations section of a
Form (i.e. Public Foo As Long) is available to routines in that form by
referencing the variable name (i.e. Foo), or to modules or forms other than
the declaring form by explicitly referring to the variable with its formname
as a prefix (i.e. Form1.Foo). The variable remains valid as long
as the form is loaded.
A variable DIM'med Private in the general declarations section of a BAS
module is available routines only in that bas module. The Private keyword
is not available in VB2 or 3; use a standard DIM statement.
A variable DIM'med Public (or Global in VB2 or 3) in the general
declarations section of a BAS module is available to all routines in all
forms and bas modules.
A variable DIM'med inside any sub or function that has the same name as
a Public or Global variable takes precedence over the Public one in that
routine where it is DIM'med. Its initial value is 0 or empty. The Public
variable's contents is not affected by use of the local variable of the same
name. The local variable is destroyed upon exiting that routine; the global variable
remains valid. Download a VB4 demo and view the code. Generally, using the
same name for a Public and Local variable is considered poor programming practice