It s good programming practice to use standard prefixes with your controls and variables . This ensures your code remains clear and understandable. The following list provides an overview of popular conventions:
ITEM | PREFIX | EXAMPLE |
---|---|---|
Form | frm | frmMain |
Class | cls / C | clsOrder |
Module | mod | modGeneric |
Label | lbl | lblUsername |
LinkLabel | lnk | lnkVisitSite |
Button | btn | btnOK |
TextBox | txt | txtPassword |
CheckBox | chk | chkRemember |
RadioButton | rad | radMale |
GroupBox | grp | grpOptions |
PictureBox | pic | picAuthor |
DataGrid | grd | grdOrders |
ListBox | lst | lstSubscribed |
CheckedListBox | clst | clstExtras |
ComboBox | cbo | cboRoomNumber |
TreeView | tvw | tvwFolders |
ListView | lvw | lvwFiles |
TabControl | tab | tabSettings |
DateTimePicker | dtp | dtpAppointment |
Timer | tmr | tmrCheck |
Splitter | spl | splGeneral |
ProgressBar | pbar | pbarTimeLeft |
RichTextBox | rtf | rtfDocument |
ImageList | imgl | imglToolbar |
ToolBar | tlb | tlbMain |
MenuItem | mnu | mnuFileExit |
String | str | strAnalysis |
Date | dat | datLastVisit |
Boolean | bln | blnFlag |
Short | sht | shtCurrent |
Decimal | dec | decRate |
Long | lng | lngSystemID |
Integer | int | intCount |
Byte | byt | bytAge |
Char | chr | chrFirst |
Single | sgl | sglRemaining |
Double | dbl | dblTotalBalance |
Structure (User-Defined Type) | udt | udtCustomer |
Object | obj | objRandom |
DataSet | ds | dsmembers |
DataRow | dr | drEntry |
OleDbConnection or SqlConnection | conn | connLuxor |
OleDbCommand or SqlCommand | cmd | cmdDelete |
OleDbDataAdapter or SqlDataAdapter | da | daUserList |
OleDbDataReader or SqlDataReader | rdr | rdrItems |
Crystal Report | rpt | rptSales |
It is also common practice to prefix module-level variable declarations with m and global declarations with g ”although, as ever, this is not enforced and simply serves as a suggestion to help assist your development.
You can also find a full list of recommended code styling guidelines for your Visual Basic program, by looking up naming conventions, Visual Basic in the help index.