Share via


Visual Basic Concepts

The One-Minute Terminologist

The following is a whirlwind tour of terms you'll meet in discussions of Visual Basic objects and their capabilities. If you're coming to Visual Basic from another programming language, or from having worked with ActiveX (formerly OLE) terminology, this topic will help you make the transition.

If you're new to objects, you may find it all a little bewildering. That's okay — by taking a quick tour of the terms you're going to meet, you'll start forming a picture of how they fit together. As you discover more about objects in the rest of this chapter, you can return to this topic to integrate each piece of information into the whole.

Here Goes

Objects are encapsulated — that is, they contain both their code and their data, making them easier to maintain than traditional ways of writing code.

Visual Basic objects have properties, methods, and events. Properties are data that describe an object. Methods are things you can tell the object to do. Events are things the object does; you can write code to be executed when events occur.

Objects in Visual Basic are created from classes; thus an object is said to be an instance of a class. The class defines an object's interfaces, whether the object is public, and under what circumstances it can be created. Descriptions of classes are stored in type libraries, and can be viewed with object browsers.

To use an object, you must keep a reference to it in an object variable. The type of binding determines the speed with which an object's methods are accessed using the object variable.**An object variable can be late bound (slowest), or early bound. Early-bound variables can be DispID bound or vtable bound (fastest).

A set of properties and methods is called an interface. The default interface of a Visual Basic object is a dual interface which supports all three forms of binding. If an object variable is strongly typed (that is, Dim … As classname),**it will use the fastest form of binding.

In addition to their default interface, Visual Basic objects can implement extra interfaces to provide polymorphism. Polymorphism lets you manipulate many different kinds of objects without worrying about what kind each one is. Multiple interfaces are a feature of the Component Object Model (COM); they allow you to evolve your programs over time, adding new functionality without breaking old code.

Visual Basic classes can also be data-aware. A class can act as a consumer of data by binding directly to an external source of data, or it can act as a source of data for other objects by providing data from an external source.

On to Symphony Hall

Whew! If all of that seemed like old hat to you, you'll cruise through the rest of this chapter. If not, don't worry — there are strategically located explanations of all these terms sprinkled through the text (and presented at a much less frenetic pace).