Click Here!
home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Visual Basic 6 Black Book
(Publisher: The Coriolis Group)
Author(s): Steven Holzner
ISBN: 1576102831
Publication Date: 08/01/98

Bookmark It

Search this book:
 
Previous Table of Contents Next


Control Prefixes

The suggested Microsoft control prefixes appear in Table 1.5. As you can see, there’s a suggested prefix for every standard type of control.

Table 1.5 Control prefixes.
Control Type Prefix
3D panel pnl
ADO data ado
Animated button ani
Checkbox chk
Combo box, drop-down list box cbo
Command button cmd
Common dialog dlg
Communications com
Control (used within procedures when the specific type is unknown) ctr
Data dat
Data-bound combo box dbcbo
Data-bound grid dbgrd
Data-bound list box dblst
Data combo dbc
Data grid dgd
Data list dbl
Data repeater drp
Date picker dtp
Directory list box dir
Drive list box drv
File list box fil
Flat scroll bar fsb
Form frm
Frame fra
Gauge gau
Graph gra
Grid grd
Header hdr
Hierarchical flex grid flex
Horizontal scroll bar hsb
Image img
Image combo imgcbo
Image list ils
Label lbl
Lightweight checkbox lwchk
Lightweight combo box lwcbo
Lightweight command button lwcmd
Lightweight frame lwfra
Lightweight horizontal scroll bar lwhsb
Lightweight list box lwlst
Lightweight option button lwopt
Lightweight text box lwtxt
Lightweight vertical scroll bar lwvsb
Line lin
List box lst
List view lvw
MAPI message mpm
MAPI session mps
MCI mci
Menu mnu
Month view mvw
MS chart ch
MS flex grid msg
MS tab mst
OLE container ole
Option button opt
Picture box pic
Picture clip clp
Progress bar prg
Remote data rd
Rich text box rtf
Shape shp
Slider sld
Spin spn
Status bar sta
System info sys
Tab strip tab
Text box txt
Timer tmr
Toolbar tlb
Tree view tre
Up-down upd
Vertical scroll bar vsb

If you work with databases, take a look at Table 1.6, which holds the prefixes for Data Access Objects (DAO).

Table 1.6 Data Access Object prefixes.
Database Object Prefix
Container con
Database db
DBEngine dbe
Document doc
Field fld
Group grp
Index ix
Parameter prm
QueryDef qry
Recordset rec
Relation rel
TableDef tbd
User usr
Workspace wsp

Besides the prefixes in Table 1.6, Microsoft recommends prefixes for menus and constants as well, and we’ll take a look at these now to round off our discussion on this topic.

Menu And Constant Prefixes

Microsoft recommends that you prefix menu controls with mnu and then the menu name followed by the menu item name. For example, the File menu’s Open item would be named mnuFileOpen, and the Edit menu’s Cut item would be named mnuEditCut. Microsoft also recommends that constant names (you declare constants with the Const statement) should be mixed case with capitals starting each word, for example:

Const DiskDriveNumber = 1        'Constant
Const MaximumFileCount = 1024    'Constant


TIP:  Although standard Visual Basic constants do not include data type and scope information, prefixes like i, s, g, and m can be useful in understanding the value or scope of a constant.

That completes the prefix and naming conventions. As you can see, there are prefixes for just about every type of programming construct available. You’re not constrained to use them, but if you work in a team, they can be extremely helpful.

Microsoft also has a set of suggestions on commenting your code, and we’ll take a look at those suggestions now.

Code Commenting Conventions

In general, you should add a new comment when you declare a new and important variable, or wish to make clear some implementation method. Ideally, procedures should only have one purpose and be named clearly enough so that excessive comments are not required. In addition, procedures should begin with a comment describing what the procedure does, and that comment should be broken up into various sections. The Microsoft recommendations for those sections appear in Table 1.7; note that not all sections may be applicable for all procedures.

Table 1.7 Procedures for starting comment block sections.
Section Heading Comment Description
Purpose What the procedure does
Assumptions List of each external variable, control, open file, or other element that is not obvious
Effects List of each affected external variable, control, or file and the effect it has (only if this is not obvious)
Inputs Each argument that may not be obvious; arguments are on a separate line with inline comments
Returns Explanation of the values returned by functions


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.