7.14. Scope of Declarations

You have seen declarations of various Visual Basic entities, such as classes, methods, variables and parameters. Declarations introduce names that are used to refer to such entities. A declaration’s Scope is the portion of the program that can refer to the declared entity by its name without qualification. Such an entity is said to be “in scope” for that portion of the program. This section introduces several important scope issues.

The basic scopes are as follows:

  1. Block scope— The scope of a variable declared in a block is from the point of the declaration to the end of the block (e.g., a variable declared in a control statement’s body is in scope only until the end of that control statement).

  2. Method scope— The scope ...

Get Visual Basic 2005 for Programmers: Deitel Developer Series, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.