Naming Conventions Used in Programs

(I) Controls

CONTROL CLASS           PREFIX
Check Box                 chk
Combo Box                 cbo 
Command Button            cmd 
Form                      frm 
Frame                     fra 
Grid                      grd 
Horizontal Scroll Bar     hsb 
Image                     img 
Label                     lbl 
List Box                  lst 
Option Button             opt 
Picture Box               pic 
Text Box                  txt 
Vertical Scroll Bar       vsb 

Controls that remain unchanged during the running of the program are not required to conform to this naming convention. These typically include Labels and Shapes (including lines and rectangles). For example, unchanging labels could be given names such as Label1, Label2, etc.

(II) Variables

All variables start with a prefix that indicates the scope and data type. Here, the prefix consists of all letters preceding the first underscore in a variable name, with the scope designation preceding that of the data type.

Scope:

m = module-level declared in the (declarations) section of (General)
l = local declared within the procedure in which the variable is used; 
    this is usually omitted. 

Data Type:

s = Single Precision (real number)
i = Integer 
st = String 
b = Boolean (True or False) 

Return to List of Visual Basic Examples