Share via


Visual Basic Concepts

Externally Creatable Objects

Part of the additional importance of object models in components comes from the fact that components can provide objects in two different ways — as externally creatable objects or as dependent objects.

In an ordinary program that uses private objects, you can create objects from any class the program defines. A client application, however, can only create objects from some of the classes a component provides. Externally creatable objects are those that a client application can create using the New operator with the Set statement, by declaring a variable As New, or by calling the CreateObject function.

When a client uses one of these mechanisms to request an externally creatable object, the component returns a reference the client can use to manipulate the object. When the client sets the last variable containing this reference to Nothing, or allows it to go out of scope, the component destroys the object.

You can make a public object externally creatable by setting the Instancing property of the class module to any value except Private or PublicNotCreatable.

For More Information   A discussion of the Instancing property can be found in "Instancing for Classes Provided by ActiveX Components." Dependent objects are discussed in "Dependent Objects."