Local variable : Variable Scope « Language Basics « VBA / Excel / Access / Word






Local variable

 

Public Sub Procedure1()
    Dim intVariable1        As Integer
    Dim intVariable2        As Integer
    intVariable1 = 1
    intVariable2 = 2
    Debug.Print intVariable1
    Debug.Print intVariable2
End Sub
Public Sub Procedure2()
    Dim intVariable1        As Integer
    intVariable1 = 100
   Debug.Print intVariable1
End Sub
Public Sub TestLocal()
    Procedure1
    Procedure2
    Procedure1
End Sub

 








Related examples in the same category

1.Procedure-Level (Local) Variables
2.module-level variable declared with Private statement
3.Understanding Module-Level Variables
4.Public Variables
5.Understanding and Using Static Variables
6.sub module scope
7.Module level variable
8.Local variables are available only in the procedure where they are declared
9.Private module variable