The scope of a VB 6 variable decide the lifetime of that variable. There are 3 levels of scope for a variable in Visual Basic 6.
In this article, you will learn about the scope of variables with examples in a Visual Basic 6 project.
Level of Scope
The scope in many programming languages is either a global scope or a local scope. We will list out the global scope and local scope for a variable in visual basic 6.
Visual Basic 6 has 3 levels of scope:
- Module Level with Public (Global)
- Form or Module level (Global only to the Module).
- Procedure Level (Local scope)
Module Level With Public
Variables declared in the general section of the code editor using keyword Public are visible in all forms and modules throughout the VB 6 Project.