when do i use dem/public/private/static when declaring a variable
However, you can preserve the value of a local variable by making the variable static. Use the Static keyword to declare one or more variables inside a procedure, exactly as you would with the Dim statement: Static Depth.
By declaring the access modifier you are forcing the variable to be what you specify: 1  public: Visible to everyone. 2  protected: visible to children. 3  private: Not visible to anybody outside the defining class.