Brief Word on Naming the Class

All things have names, and class modules are no different. The name you give a class module, however, is the name that is shown in both the Project Explorer and the Object Browser, so it should be something relevant and meaningful. A more in-depth discussion on naming objects comes later in this chapter.

Open the Object Browser by selecting View O Object Browser, or by pressing F2.

To name your class, display the Properties window by selecting it from the View menu, or by pressing F4. Then enter a name in the (Name) property.

Access also enables you to create a hidden class (or module) by prefixing the name of your module with an underscore. Figure 13-4 shows a class named clsHidden that appears as hidden in the Object Browser when Show Hidden Members is enabled.

Figure 13-4

Another property in the Properties box has not been covered: Instancing. There are several other concepts to introduce before discussing this property, but later in the chapter you'll explore it and look at a trick using the Instancing property to allow for additional reusability.

Figure 13-5 shows the clsClassroom class in the Object Browser.

Object Browser

<AII Libraries»

- < > f

- 1

Classes CheckBox

Members of'clsClassroom" ^ AddStudent

©jclsCiassroorn ;

III? mintStudents

© CodeData

Students

© CodeProject <ip CollatingOrderEnum © Collection ColorConstants

Public Property Students As Integer read-only

Member of Access 2007 Book.cls Classroom

Figure 13-5

Notice that details of the selected property or method are displayed under the Classes pane. You can filter the Classes pane by selecting a project or library from the Project/Library combo box, as shown in Figure 13-6.

Object Browser

|<AII Libraries» <AII Libraries» Access

-

■J Ä > .?■ ft i

rIDA0

stdole IVBA

embers of "clsClassroom"

AddStudent 1 mintStudents

IS CodeData

i

Students

0 CodeProject tip CollatingOrderEnum 0 Collection ColorConstants

<AII Libraries>

Figure 13-6

A more detailed explanation of the Object Browser is given in Chapter 4. You can't do any damage by experimenting in the Object Browser, however, so feel free to look around and click all the buttons.

0 0

Post a comment