The idea behind scope is that a variable or a constant can only be used within the context it is defined.
There are many levels to a program. From highest to lowest, they are generally:
1. Pages
Forms
ClassesASP, JSP
Visual Basic
Visual Basic, Java, C++2. Procedures
Functions
MethodsVisual Basic
Visual Basic
Java/C++3. Code Blocks Java, C++, Visual Basic .Net
Each level is contained within the level above:
A variable or constant declared at a particular level can be used at that level or by any level below, but not by any level above:
Generally, the scope of a variable is:
local Levels 2 and 3 above public
privateLevel 1 above