When You Should Set the Name Property in VB6 Programming?

Monday, September 7, 2009 ·

One of the important thing is setting the Name of object property when you developing VB6 applications. And in the previous posting I've written that you should set the name with adopting the Standard Naming Convensions in order easier for other developer in understanding your program. And also you should give the descriptive name that according to the purpose of the object.

Now, the question is "when you should set the name property?". The recommended time to set the Name property is as soon as after you create the object. Why this time? Because if you set the name (change the name) property after you write coding for the object, it makes the code in your applications will loss its association with the control.

When you change a name property of an object, the sub procedure that associated with the object won't be changed automatically, so code seems lost. For example: You have a TextBox named Text1, and you have written some codes in Sub Text1_Change() and Sub Text1_LostFocus(). When you change the name to other name (for example txtFirstName), the name of Sub Text1_Change() and Sub Text1_LostFocus() won't be changed to new name automatically. So the association between the object and the code is lost.

Now, what you should do if you have to change the object name after you write your code that associated with the object?


0 comments:

Post a Comment