|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
Visual Basic Naming Conventions
Visual Studio .NET 2003
When you name an element in your Visual Basic .NET application, the first character of that name must be an alphabetic character, a digit, or an underscore. The following suggestions also apply to naming:
- Begin each separate word in a name with a capital letter, as in
- Begin function and method names with a verb, as in
- Begin class and property names with a noun, as in
- Begin interface names with the prefix "I", followed by a noun or a noun phrase, like
IComponent, or with an adjective describing the interface's behavior, like
IPersistable. Do not use the underscore, and use abbreviations sparingly, because abbreviations can cause confusion.
- Begin event handler names with a noun describing the type of event followed by the "
EventHandler" suffix, as in "
- In names of event argument classes, include the "
- If an event has a concept of "before" or "after," use a prefix in present or past tense, as in "
ControlAdd" or "
- For long or frequently used terms, use abbreviations to keep name lengths reasonable, for example, "HTML", instead of "Hypertext Markup Language". In general, variable names greater than 32 characters are difficult to read on a monitor set to a low resolution. Also, make sure your abbreviations are consistent throughout the entire application. Randomly switching in a project between "HTML" and "Hypertext Markup Language" will lead to confusion.
- Avoid using names in an inner scope that are the same as names in an outer scope. Errors will result if the wrong variable is accessed. If a conflict occurs between a variable and the keyword of the same name, you must identify the keyword by preceding it with the appropriate type library. For example, if you have a variable called
Date, you can use the intrinsic Date function only by calling System.Date.