When creating Visual Basic object base names, remember that the base name must be descriptive even in the absence of its tag. For many programmers, the syntax Dim I As Integer for a loop variable is quite acceptable. Within LNC, however, the variable named I would become iintLoop. Single-character variable names—especially without tags—aren't allowed. Instead, create a list of short and standardized work variables to handle common daily needs. Table D.10 suggests the LNC approach to commonly used variables.
Creating Visual Basic object base names involves following the same rules listed earlier in the section “Creating Database Object Base Names.” Briefly, those rules are as follows (refer to the earlier section for full descriptions):
Spaces aren't allowed in any object name.
Object names begin with a letter and should include only letters, digits, and underscore characters.
Object names use mixed upper- and lowercase to add readability to the name.
The only non-abbreviated syntax element that can have multiple capital letters is the base name.
Object names are usually singular rather than plural.
An object's base name should include the base names of any objects it's built on, if practical.
Note
The last rule is an expanded version of the corresponding rule for database objects, which stated that table base names should propagate into names of dependent objects. In Visual Basic, that rule expands to require a reference in variable names to objects of any type that they relate to. For example, a RecordSet variable created on tblCust should be named rstCust. Also, if a string array variable of part numbers, astrPartNum, had an Integer index variable, it should include the array's base name in its own: iaintPartNum.
There's no LNC rule limiting variable name length, but common sense dictates that variable names longer than 15 or 20 characters waste a lot of keystrokes at each use. For procedure names, the VBA module editor by default shows just more than 20 characters of a procedure name, so this number is suggested as the target maximum procedure name length.
Abbreviate VBA object base name elements wherever possible by using a standardized abbreviation table such as the one explained later in the section “Standardized Abbreviations.” You can extend LNC by creating your own standard abbreviations as well. You should create and use standardized terminology in your applications wherever possible; for examples, see the later section “Standardized Terminology.”
Procedure base names follow the construction ObjectVerb, where the Object portion describes the primary object type affected (often the same as the primary argument), and Verb describes the action. This style sorts functions and subs by their target object when shown in ordered lists, as follows:
FormCtlHide FormCtlShow FormPropAdd FormPropGet FormPropSet
We find this sort order much more appealing than the commonly used alternative with VerbObject construction:
18.219.208.117