Scope rules and instance variables in VB.NET
In this article I shows you how to use instance variable and what is scope in Vb.Net application.
Scope of a variable means that a variable is in the
particular scope and you can use that variable within the the scope if the
variable is out of scope you will not able to access the variable. In Vb.Net
there are three types of scope.
- Global Scope
Global Scope means your variable have global scope in your application and
you can use that variables in anywhere in your application
- Module Scope
Module Scope means that you can use variables antwhere within the module.
- Local Scope
Local Scope means you can use your declared variable only within the
procedure where you declared the variable.
Instance variables are frequently used for passing the
reference values within the application like in given below example we create a
shared variable name as value.
Example to demonstrate the working with instance
variable with the scope
in" & " FrmScoping_Load is " &
in Method is " & value & " after entering
value += 5
in Method is " & value & " before quitting
In this article you can see how I use a shared variable
in hole class and go through this code you can understand the scope of class.