Visual Basic Concepts

Code Components

See Also

Code components are like libraries of objects. A client application uses a code component by creating an object from one of the classes the component provides, and invoking the object’s properties, methods, and events.

Note   In earlier documentation, code components were referred to as OLE Automation servers.

You might create a code component that provides extended financial functions for spreadsheet users, or you might encapsulate business rules used by your organization, so that all applications process the same data consistently.

With Visual Basic, you can build code components to run in process, allowing faster access to their objects, or out of process, so that they have separate threads of execution from their clients.

You can use code components to provide standard libraries of modal and modeless dialogs — although frequently a code component will have no user interface.

Visual Basic allows you to suppress all forms of user interaction, even system alert messages, and to record such events in the system log. This unattended execution capability is extremely useful for code components designed to run on remote computers.

In an out-of-process code component that has been designed for unattended execution, you can mark a class as multithreaded. Each object created from such a class can be on a separate thread of execution within the out-of-process component.

To simplify the creation of reusable code libraries that can also be used with desktop tools (such as the Microsoft Office suite), Visual Basic allows you to mark objects in a code component as global, so that their methods can be invoked without explicitly creating an instance of the global object.

Whatever you used to call them, it’s a whole new ball game.

For More Information   A step-by-step introduction to in-process code components, including in-process debugging, can be found in "Creating an ActiveX DLL." "Creating an ActiveX Exe Component" gives a similar introduction to the creation and debugging of out-of-process code components. Advanced topics are covered in "Building Code Components." Topics of general interest to component designers can be found in "General Principles of Component Design" and "Debugging, Testing, and Deploying Components."