Naming Restrictions

Variable Scope

  Where Declaration Keyword Used (Scope & Lifetime)
Declaration Keyword In Procedure of Any Module In Declaration Section of Non-Standard Module In Declaration Section of Standard Module (.bas)
Dim Procedure & Procedure Module & Application Module & Application
Static Procedure & Application NA NA
Private Procedure & Procedure Module & Application Module & Application
Public NA Global & Application Global & Application
Const Global & Application Global & Application Global & Application

A variable, constant, or object variable is usually declared before using it. Explicit variable declaration is not required but highly recommended. For one, it helps Visual Basic spell check your variables. If using it be sure to use the Option Explicit keyword in the Declarations section of the module's code. Syntax:

{Dim | Static | Private | Public} Variable [As DataType]
{Dim | Static | Private | Public} Const Constant [As DataType] = expression
{Dim | ReDim | Static | Private | Public} ObjectVariable As [New] ClassOrObjeccodeype
...
Set <ObjectVariable> = [New] Object

Array Variables

Declare arrays as you would a variable but with these modifications:

Coding Conventions

Naming Conventions

Page Modified: (Hand noted: ) (Auto noted: )