Prefixes aren't just for variables. All standard objects (including forms and controls) have a three-character prefix, as described in Tables 3-3, 3-4, and 3-5. Learn and use these prefixes consistently if you're not already. Correctly applying the standard three-character prefixes to all your variables and objects makes your code more self-documenting and easier to maintain.
Control | Prefix | Example |
---|---|---|
Check box | chk | chkPrint |
Checked list box | chklst | chklstLunchItems |
Combo box | cbo | cboTitle |
Context menu | ctx | ctxContactsMenu |
Control (generic) | ctl | ctlCurrentControl |
Data grid | grd | grdOpenTasks |
Domain up down | dom | domPrimaryDomain |
Button | btn or cmd | btnOK; also acceptable is cmdOK |
Form | frm | frmMain |
Group box | grp | grpDisplayOptions |
Help provider | hlp | hlpPrimaryHelp |
Horizontal scroll bar | hsb | hsbWidth |
Image list | img | imgFolderIcons |
Label | lbl | lblHelpMessage |
Link label | lnk | lnkHomePage |
List box | lst | lstResultCodes |
List view | lvw | lvwActiveUsers |
MDI child form | mdi | mdiContact |
Menu item | mnu | mnuFileOpen |
Notify icon | nfi | nfiTrayIcon |
Numeric up down | num | numAge |
Open file dialog | opn | opnSelectFile |
Panel | pnl | pnlSettings |
Progress bar | prg | prgProgress |
Radio button | opt (for option) | optSpanish |
Picture box | pic | picDiskSpace |
Rich text box | rtf | rtfLayout |
Save file dialog | sav | savSavePicture |
Status bar | sbr | sbrStatus |
Tab | tab | tabColorOptions |
Text box | txt | txtAddress |
Timer | tmr | tmrAlarm |
ToolTip | tip | tipQuickTip |
Toolbar | tbr | tbrMain |
Track bar | trk | trkColorDepth |
Tree view | tre | treFolders |
Splitter | spl | splMainSplitter |
Vertical scroll bar | vsb | vsbHeight |
Note
In previous versions of Visual Basic, buttons were called command buttons, and therefore used the prefix cmd. This prefix is so common that it's fully acceptable to use this prefix in Visual Basic .NET. However, using btn is preferred. In addition, what are now called radio buttons used to be called option buttons. (Actually, they were radio buttons, then option buttons, and now radio buttons again.) Use opt for these controls.
Object | Prefix | Example |
---|---|---|
Class | cls | clsEmployee |
Form | frm | frmLogin |
Module | mdl | mdlUtilities |
User control | ctl | ctlGhanttChart |
Object | Prefix | Example |
---|---|---|
Connection | cnn | cnnContacts |
Command | cmd | cmdUpdateContacts |
DataSet | dst | dstCompanies |
DataView | dvw | dvwCustomers |
DataAdapter | adp | adpPrimary |
DataReader | drd | drdResults |
DataTable | dtb | dtbNotes |
DataColumn | dcl | dclLastName |
DataRow | drw | drwCurrentUser |
DataRowView | drv | drvCurrentUser |
DataRelation | drl | drlContactsAndEmailAddresses |
DataException | dex | dexCurrentException |
Transaction | trn | trnSellStock |
UniqueConstraint | ucst | ucstConstraint |
ForeignKeyConstraint | fcst | fcstConstraint |
StoredProcedure | prc | prcComputeSalesTax |
Parameter | prm | prmFirstName |