|
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
To access the contents, click the chapter and section titles.
Visual Basic 6 Programming Blue Book: The Most Complete, Hands-On Resource for Writing Programs with Microsoft Visual Basic 6!
The Skeleton In Your ProgramTo use some official terminology, we can say that Visual Basic is an applications framework. It provides the bonesthe skeleton, if you willfor your applications. All the fundamental building blocks of a Windows program are included in Visual Basic, waiting for you to use them. No longer do you have to write dozens of lines of code to display a dialog box or an option button. (Yes, believe it or not, thats the way Windows programs used to be written.) The process is so simple that you are free to spend almost all your time and mental energy working on the important parts of your programthose elements that make it unique in the world of Windows programs. The idea hereand I know Im repeating myself, but this is important, so listen upis that a lot of what goes on in any Windows program goes on in every Windows program. Each time you put a text box or a menu in a program, a thousand other programmers are doing the samefrom London to Sydney, from Bombay to Cherepovets. (Look it up. Hint: Its not in Silicon Valley.) The folks at Microsoft reasoned, Why should every programmer have to spend time writing the same code for the same program elements? Lets do all that basic stuff for them. Thus was born one of the fundamental ideas behind Visual Basic: the concept of an applications framework. Let the development toolthat is, Visual Basicdo all the boring, repetitive work and free the programmer to work on the creative aspects of the program. Which brings us to an essential rule: Dont reinvent the wheel. Visual Basics job, then, is to provide a whole bunch of the wheels that your Windows programs need. The time you might have spent reinventing these wheels will be better spent creating meaningful, unique program features. I hope youll forgive the mixing of metaphorsone minute Visual Basic is a framework, the next its a skeleton, and now its wheelsbut this is a critical point. When youre creating a Visual Basic application that requires a certain feature or capability, the first question to ask is whether Visual Basic provides what you need. Visual Basic doesnt have everything, but you will be surprised to discover just how much it does have. These wheels are, of course, the components that I spoke about earlier. A Framework Is Not EnoughThe framework provided by Visual Basic is pretty darned amazing. Visual Basics framework is so complete, in fact, that you can create an impressive-looking program without writing a single line of code (or very few lines, at most). The program could have multiple windows, each containing an impressive array of option buttons, lists, text boxes, and so on. Menus would display when needed, dialog boxes would come and go, and everything would look terrific. Only one thing would be lacking, but its a very important thingthe program wouldnt do anything (other than look nice). The meaningful parts of the programthe parts that make it into a word processor, a stock market analyzer, or a multi-media presentationare missing. This is what you, the programmer, must add. To teach you how to do this is the main goal of this book. As youll see in this and subsequent chapters, the task is divided into two main parts:
In the remainder of this chapter, well take a closer look at the different parts of Visual Basic. I know youre probably itching to sit down at your computer and get to work with Visual Basic, and I promise some hands-on work in the next chapter. But please try to stay with me for the next few pages; I think youll find this theoretical material to be a real help down the road. Objects Is ObjectsThe framework that Visual Basic provides comes in the shape of components, or objects. Sometimes, youll see the term class used as well. This confusing terminology is unfortunate but theres not much to be done about it. Just remember, when you see component, object, or class, it refers to something that is reusable and independent and can be used in a program to perform some useful function. Software components have been around for a long time, sometimes under another name. The complexity of Windows programming, however, and the continued development of sophisticated programming tools, such as Visual Basic, have made an increased reliance on software components not only possible, but necessary.
A software component is nothing more than a self-contained chunk of software that performs a specific task. The task can be just about anythingfrom the very simple, such as calculating a cube root, to the very complex, such as providing a spreadsheet-like grid in a window. The self-contained part of the definition is important. To reap the maximum benefits from a software component, you should be able to take it off the shelf (so to speak) and drop it directly into your program without any fuss. The more software components you have at your disposal, the easier your programming will be. Instead of writing, testing, debugging, and rewriting the code yourself, all you do is pop the component into your program. Remember the wheels I was talking about earlier in the chapter and our rule, Dont reinvent the wheel? Software components are those ready-made wheels. You may be thinking that Visual Basics objects are software components, and you are 100-percent correct. This is one of the three levels of software components in Visual Basic. By themselves, they are powerful, but theres more. On a second level, Visual Basic permits you to create your own software components. As you gain more programming experience, youll probably find yourself doing certain tasks over and over in different programs. This is particularly true if all your programming tends to fall in a specialized category, such as graphics or database. For example, many of your programs may need a dialog box that lets the user select from a palette of background patterns. Whatever the specifics, Visual Basic provides the tools that permit you to wrap the functionality in a self-contained component that you can then easily drop into future programs. The third level at which Visual Basic uses software components is that of custom controls (also referred to as OCX and ActiveX controls). A custom control is not part of the Visual Basic package, but is provided by Microsoft or another vendor as an enhancement. When you install a custom control, it is available within Visual Basic just like the controls that come with Visual Basic. As you plan or work on a project, you should have some knowledge of the custom controls that are available. Some are free or available for minimal cost as shareware, while others are commercial products at various prices. Finding just the right custom control can often save you days or weeks of tedious programming and is usually well worth any associated cost.
|
![]() |
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. |