Visual Basic Naming Conventions

 

MS Explorations | MS Academics | Middle School | The American School in Japan

Visual Basic Naming Conventions

Identifying objects in Visual Basic is easier if you use name that reminds you what the object or variable is. For example, a piece of code like:

x.height = y.height + z.text

doesn't even give a hint as to whether it is changing the height of a text box, label, form, image.... It helps to know what the object is.

It's become a convention for Visual Basic programmers to use a three letter lower-case prefix to identify these objects. Some of the more common name prefixes are:

Object Prefix Example
combo box cbo cboCost
check box chk chkAddresses
command button cmd cmdRevert
data dat datName
directory list box dir dirSource
drive list box drv drvTarget
file list box fil filSource
frame fra fraColor
horizontal scroll bar hsb hsbZoom
image img imgFlyingDisk
label lbl lblProduct
line lin linUnderline
list box lst lstGreeting
OLE ole oleObject1
option button opt optBlue
picture box pic picAirplane
shape shp shpWireScreen
text box txt txtWagerAmounts
timer tmr tmrStopInput
vertical scroll bar vsb vsbContrast
   

This site best viewed with 2001 or later versions of Netscape, Internet Explorer, Mozilla, or Opera.

Original Content ©2001-2004 by Derrel Fincher. Other rights reserved by individual authors