01 02 6MS2GHFAHHN7NNGL2R7HGTKDZPLNYO4N36EFRBY




Visual Basic 6 Programming Blue Book: The Most Complete, Hands-On Resource for Writing Programs with Microsoft Visual Basic 6!:RAD, Baby
function GetCookie (name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) { var end = document.cookie.indexOf (";", j); if (end == -1) end = document.cookie.length; return unescape(document.cookie.substring(j, end)); } i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } var m1=''; var gifstr=GetCookie("UsrType"); if((gifstr!=0 ) && (gifstr!=null)) { m2=gifstr; } document.write(m1+m2+m3);            Keyword Title Author ISBN Publisher Imprint Brief Full  Advanced      Search  Search Tips Please Select ----------- Components Content Mgt Certification Databases Enterprise Mgt Fun/Games Groupware Hardware IBM Redbooks Intranet Dev Middleware Multimedia Networks OS Prod Apps Programming Security UI Web Services Webmaster Y2K ----------- New Titles ----------- Free Archive 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! (Publisher: The Coriolis Group) Author(s): Peter G. Aitken ISBN: 1576102815 Publication Date: 08/01/98 function isIE4() { return( navigator.appName.indexOf("Microsoft") != -1 && (navigator.appVersion.charAt(0)=='4') ); } function bookMarkit() { var url="http://www.itknowledge.com/PSUser/EWBookMarks.html?url="+window.location+"&isbn=0"; parent.location.href=url; //var win = window.open(url,"myitk"); //if(!isIE4()) // win.focus(); } Search this book:  














Previous
Table of Contents
Next




The Skeleton In Your Program
To use some official terminology, we can say that Visual Basic is an applications framework. It provides the bones—the skeleton, if you will—for 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, that’s 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 program—those elements that make it unique in the world of Windows programs.
The idea here—and I know I’m repeating myself, but this is important, so listen up—is 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 same—from London to Sydney, from Bombay to Cherepovets. (Look it up. Hint: It’s 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? Let’s 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 tool—that is, Visual Basic—do 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: Don’t reinvent the wheel.
Visual Basic’s 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 you’ll forgive the mixing of metaphors—one minute Visual Basic is a framework, the next it’s a skeleton, and now it’s wheels—but this is a critical point. When you’re 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 doesn’t 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 Enough
The framework provided by Visual Basic is pretty darned amazing. Visual Basic’s 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 it’s a very important thing—the program wouldn’t do anything (other than look nice). The meaningful parts of the program—the parts that make it into a word processor, a stock market analyzer, or a multi-media presentation—are missing. This is what you, the programmer, must add. To teach you how to do this is the main goal of this book. As you’ll see in this and subsequent chapters, the task is divided into two main parts:

•  Select those components from the Visual Basic framework that are best suited to your program.
•  Write Basic code to tie the framework components together and provide the needed functionality.

In the remainder of this chapter, we’ll take a closer look at the different parts of Visual Basic. I know you’re 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 you’ll find this theoretical material to be a real help down the road.

Objects Is Objects
The framework that Visual Basic provides comes in the shape of components, or objects. Sometimes, you’ll see the term class used as well. This confusing terminology is unfortunate but there’s 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.

TIP:  Is Visual Basic Object-Oriented Programming (OOP)?
In a word, sort of. Okay, I know that’s two words, but it’s the best answer I can offer. With all the talk of objects in Visual Basic, you might well think that Visual Basic lets you do “real” OOP like C++ and Java. While Visual Basic lets you perform some programming tasks in a manner that is similar to OOP, it does not have all the characteristics of a true object-oriented language. For example, it lacks inheritance and polymorphism. The term object is used differently in Visual Basic. This does not mean that Visual Basic is inferior in some way; it’s just a different approach to programming (and for many purposes, a better one).


A software component is nothing more than a self-contained chunk of software that performs a specific task. The task can be just about anything—from 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, “Don’t reinvent the wheel”? Software components are those ready-made wheels.
You may be thinking that Visual Basic’s 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 there’s more.
On a second level, Visual Basic permits you to create your own software components. As you gain more programming experience, you’ll 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.



Previous
Table of Contents
Next






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.



Wyszukiwarka

Podobne podstrony:
t informatyk12[01] 02 101
2010 01 02, str 067 073
01 02
01 02 Taikyoku Sono Ichi, Ni
TI 01 02 27 T pl(2)
KOMINY 6 7 01 02
2010 01 02, str 054 057
312[01] 02 122 Arkusz egzaminacyjny
IN1 01 02
2010 01 02, str 100 105
Ujawniono kulisy wojny w Iraku Saddam przeczytał list i wyszedł (01 02 2009)
STARTER 188 01 02 Instrukcja i Schemat
A17 Energia pola elektrycznego (01 02)
TI 01 02 12 T pl(2)

więcej podobnych podstron