VB Notation: Understanding the Name Property in VB2005
Visual Studio assigns a default name to a form or control instance, like Form1, Form2, Button1, Button2 etc..
Meaningful and consistent names are used for forms and control instances created on a form. Form names are created beginning with the prefix "frm" to denote a form, followed by a descriptive name. Example "frmMain". Control instances are similarly named with a descriptive prefix.
In VB2005, the name property of a form or control instance must adhere to the following rules:
- The first character of the name must be a letter
- The subsequent characters of the name can be letters,numbers, or the underscore character.
- The name must be fewer than 255 characters in length.
- Names can not contain spaces.
- A name can not include any special characters other than underscore character.
- The name of each form and control instances created on the form must be unique. Control instances created on different forms can have the same value for the Name property.
A list of common prefixes(Hungarian Prefix) for the control are given below:
- Button control ---- "btn"
- Label control -----"lbl"
- OpenFileDialog control ------"ofd"
- Picturebox control --- "pic"
- Tooltip control --- "tip"
- Combo Box control -- "cbo"
- List Box -----"lst"
- Text Box ----"txt"
- GroupBox ---"grp"
- RadioButton ---"rad"
In addition to the prefix denoting the type of control, control instance names are chosen to describe the purpose of the control instance. For example an Exit button might have the name btnExit.
If two control instances are given the same name property value, a dialog box appears indicating the error.
- Pascal Notation
- VB Structure
- Java Notation
- Form feed character
- Select case identifier
- Goto label label identifier
- What is asp.net?
- Radio button which property to set?