Naming Conventions in Visual Basic
Order, Logic and Organization are all very crucial in programming. This is important for several reasons: 1) Keeps your program clean and neat, 2) allows you to easily see each object and quickly identify the object and its purpose.
Object: Anything that we place on our form.
Each object has a name property.
i.e. Command button that is placed on the form is called Command1. Imagine if you had 10-15 different command buttons?
We need to uniquely name each object so as not to confuse it with other objects.
The format for naming conventions is as follows:
1. Each object is given a three letter prefix that identifies the type of object that it is.
2. The object is given a name that refers to what it does. This must have a capital letter to start it.
3. The prefix and the name are put together with no space.
Example:
On my form I have a command button that the user will click on to exit the program. The prefix will be cmd adn the name will be Exit. Put them together and the name of the object will be cmdExit
A text box for the user to enter their first name. The prefix will be txt adn the name will be Firstname. The name property of the object will be txtFirstname.
Click here for more a table regarding naming.
Back