After all of this discussion of classes and objects, you might be asking yourself, why all the fuss about objects? What are the advantages of using objects?
The real benefit of objects is that, developed properly, they provide software that is reusable and robust. The continuing dilemma of software development has been to create reliable code much faster and at lower cost. Some claim that it is an impossible task. More than a few software developers have a large sign posted above their doors: “Software Developed: Fast, Cheap, Good. Choose Two.”
Although object-oriented design has certainly not proved to be a magic bullet to shoot the beast of software development costs, it has helped create reliable, reusable software components. Visual Basic components include the following:
- Visible controls (the tools represented in the Visual Basic toolbox)
- Software libraries that can be reliably used by many applications (ActiveX DLLs)
- Executable programs that can be used by other programs (ActiveX EXEs)
These components make single or multiple objects available to the developer.
Different types software components are introduced and used here. You will build applications using software components, and in the case of ActiveX DLLs, build a software component yourself. Software components make possible rapid development of applications by acting as the building blocks of an application. Each software component provides a particular service to the application. One way to think about software components is to see them as servers to client applications.
How do you know which software components are available to you? Visual Basic provides the Object Browser utility to let you examine your choices.
Launching Visual Basic and the Object Browser
In this exercise, you will start Visual Basic and then use Object Browser to examine Visual Basic objects. You are provided step-by-step instructions. Don’t be alarmed if you see unfamiliar windows. The Visual Basic environment is explained in greater detail later in “Writing and Running Your First Visual Basic Program”, and “Adding Controls and Event Procedures to Form Modules.” This exercise assumes Visual Basic has been installed on your computer.
- Start Visual Basic from the Windows Start Menu.
- When Visual Basic launches, a dialog box similar to that shown below appears. If this dialog box does not appear, select Project, New from the Visual basic menu.
The Visual Basic startup dialog box contains several types of new projects, including the Standard EXE project.
- Click the Open button for a new Standard EXE project (or click OK if you opened the dialog box from the Visual Basic menu). The Visual Basic design environment will appear. It should look somewhat similar to the design environment you see illustrated earlier. It will appear similar, but not identical. As you will discover in the next section, the Visual Basic design environment is almost infinitely configurable by you. There really is no standard Visual Basic design environment.
- Press the F2 key or select View, Object Browser from the Visual Basic Menu. Object Browser will appear as shown below.
- Select the VB library from the combo box in the upper-left corner of Object Browser, as shown below (You have used this kind of Windows object before, but you may not have known that was called a combo box.)
The VB Object Browser lists the software classes available to you from the Visual Basic class library
- The classes through which you can scroll are listed on the left-hand side of Object Browser. Select the TextBox class of the VB Library and then examine the properties, methods, and events of the TextBox class in the right-hand list box.
Notice that the Object Browser icons indicate whether the class element (called a class member) is a property (the icon depicting a small hand holding a piece of paper), a method (the icon depicting a small green rectangle), or an event (the icon depicting a small thunderbolt). The image below shows these three icons.
As you examine the TextBox class and select different properties, methods, and events, observe the bottom of Object Browser where the class member is described.
Object Browser displays information about classes, in this case the TextBox classes, and shows properties of the class, class events, and class methods.
How Computers Remember
Classification of Computers