Share via


Visual Basic Concepts

What’s in a Name?

The names you select for your class modules and for their properties, methods, and events make up the interface(s) by which your component will be accessed. When naming these elements, and their named parameters, you can help the user of your component by following a few simple rules.

  • Use complete words whenever possible, as for example "SpellCheck." Abbreviations can take many forms, and hence can be confusing. If whole words are too long, use complete first syllables.

  • Use mixed case for your identifiers, capitalizing each word or syllable, as for example ShortcutMenus, or AsyncReadComplete.

  • Use the same word your users would use to describe a concept. For example, use Name rather than Lbl.

  • Use the correct plural for collection class names, as for example Worksheets, Forms, or Widgets. If the collection holds objects with a name that ends in "s," append the word Collection, as for example SeriesCollection.

  • Use a prefix for the named constants in Enums, as discussed in "Providing Named Constants for Your Component," later in this chapter.

  • Use either the verb/object or object/verb order consistently for your method names. That is, use InsertWidget, InsertSprocket, and so on, or always place the object first, as in WidgetInsert and SprocketInsert.

Important   The following names cannot be used as property or method names, because they belong to the underlying IUnknown and IDispatch interfaces: QueryInterface, AddRef, Release, GetTypeInfoCount, GetTypeInfo, GetIDsOfNames, and Invoke. These names will cause a compilation error.

For More Information   An expanded version of this list can be found in "Object Naming Guidelines," in "Standards and Guidelines."