Share via


What Is a Class?

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

A class is a definition for an object. It contains information about how an object should behave, including its name, methods, properties, and events. It is not actually an object itself, in that it does not exist in memory. When code runs that refers to a class, a new instance of the class, an object, is created in memory. Although there is only one class, multiple objects of the same type can be created in memory from that class.

You can think of a class as an object "on paper" — that is, it provides the blueprint for an object, but has no substance in memory itself. Any number of objects can be created from this blueprint. Each object created from a class has the same members: its properties, methods, and events. However, each object behaves as an independent entity; for example, one object's properties might be set to different values than those of another object of the same type.

A Microsoft® Visual Basic® for Applications (VBA) project can contain two different varieties of class modules: basic class modules, which do not have any kind of user interface associated with them, and class modules that are associated with a form or another component. Class modules that are associated with a form, for example, are identical to basic class modules, except that they exist in memory only when that form exists in memory. Examples of objects that have associated class modules are UserForms, Microsoft® Access forms and reports, the Microsoft® Word ThisDocument object, and the Microsoft® Excel ThisWorkbook and SheetN objects.

See Also

Why Build Your Own Objects? | Basic Class Concepts | Creating Property Procedures | Creating Events and Event Procedures | Extending Objects Through Interfaces | Designing Object Models | Creating Custom Objects for Web Pages