Normally, a local variable in a procedure ceases to exist as soon as the procedure stops. A static variable continues to exist and retains its most recent value. The next time your code calls the procedure, the variable is not reinitialized, and it still holds the latest value that you assigned to it. A static variable continues to exist for the lifetime of the class or module that it is defined in.
Rules
Declaration Context. You can use Static only on local variables. This means the declaration context for a Static variable must be a procedure or a block in a procedure, and it cannot be a source file, namespace, class, structure, or module.
You cannot use Static inside a structure procedure.
The data types of Static local variables cannot be inferred. For more information, see Local Type Inference.
Combined Modifiers. You cannot specify Static together with ReadOnly, Shadows, or Shared in the same declaration.
Behavior
The behavior of any local variable depends on whether it is declared in a Shared procedure. If the procedure is Shared, all its local variables are automatically shared. This includes the Static variables. There is only one copy of such a variable for the whole application. You call a Shared procedure using the class name, not a variable pointing to an instance of the class.
If the procedure is not Shared, its local variables are instance variables. This includes the Static variables. There is an independent copy of each variable in each instance of the class. You call a nonshared procedure using a variable pointing to a specific instance of the class. Any variable in that instance is independent of a variable with the same name in another instance. Therefore, they can hold different values.