Visual Basic 6 Programming Blue Book: The Most Complete, Hands-On Resource for Writing Programs with Microsoft Visual Basic 6!:Component Madness
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
Note that this dialog box has three tabs, corresponding to the following three types of components:
ControlA discrete unit that you can place on a form in your project. You have already worked with some of Visual Basics intrinsic controls; by selecting other controls on the Controls tab of the Components dialog box, you can display other controls in your Toolbox, making them available for use in your project. Most controls exist as OCX files on your disk, although some are contained in DLL files. For the most part, controls available in Visual Basic are ActiveX, a special type of component that we will cover in more detail later in the book. Available controls display as icons in the Visual Basic Toolbox.
DesignerA component that you use within Visual Basic to assist in developing your program. A designer does not show up in your final program, unlike a control, but the results of using a designer will be evident in the program. You have already used one designerthe Forms Designer. To make other designers available, select them on the Designers tab in the Components dialog box. You access designers by selecting Add ActiveX Designer from the Project menu. The designers you choose in the Components dialog box are listed here (except the Forms Designer, which is always available). What can designers do? They can help you design Web pages or create forms for database programming, for example. We will work with a couple of the designers in other parts of the book.
Insertable ObjectA software component made available by another application. The items available in this list will depend on what application programs you have installed on your system. On my system, for example, I have the Adobe Photoshop graphics program installed, so my Insertable Objects list includes Adobe Photo-shop Image. Likewise, I have the Netscape Navigator Web browser installed, so Netscape Hypertext Document is available to me in Visual Basic. These insert-able objects rely on a process called OLE automation, which permits one Windows program to make use of capabilities in another program. Well learn more about OLE automation in Chapter 10. Note that a Visual Basic program that uses an insertable object is dependent on the parent application. This means that you cannot create a Visual Basic application that uses an Adobe Photoshop image object and distribute it to end users who do not have the Photoshop application installed on their systems, because the object will not function. This is different from controls, whose functioning does not depend on anything being installed on the end users system. An insertable object that you have made available displays as an icon in the Visual Basic Toolbox.
TIP: Browsing For Controls
On the Controls tab of the Components dialog box, youll see a Browse button. Use this button to locate controls that are installed on your system, but do not show up in the dialog box because they are not properly registered. Browse to find the controls OCX file and select it. It will be registered and appear in the Controls list. Selecting the OCX file of a control that is already registered has no effect but does no harm.
References
The other way to make software components available in Visual Basic is with the References command on the Project menu. When you select this command, the References dialog box is displayed (Figure 6.2). Selected references, marked with a check, are grouped at the top of the list. Other available references are listed alphabetically below.
What exactly is a reference? To answer that question, I need to explain the concept of a Type Library. When an object is exposed for use by other applications, it is usually necessary to know the details of the objectits methods, properties, and so onto make use of it. A Type Library contains this information in a standard format. By selecting a reference in the References dialog box, you are, in effect, telling Visual Basic, Take note of the object information in this Type Library.
You would select a reference in this dialog box for two primary reasons: to make the object information available in Visual Basics Object Browser, and to enable early binding for object references in your programs. Both of these topics will be covered in more detail in Chapter 10.
Figure 6.2 The References dialog box.
Three of the entries in the References list are always selected, and you are not permitted to unselect them: Visual Basic for Applications, Visual Basic Runtime Objects and Procedures, and Visual Basic Objects and Procedures. These three sets of references are the foundation of Visual Basic itself, so they must always be available. Visual Basic will usually not let you unselect any references that are used in the current project. I say usually, because in some cases, an object is referenced in a project in a way that Visual Basic does not know about it until the program is executed or compiled. In these situations you are not prevented from unselecting the associated reference in the References list, but you will receive an error message when you try to run or compile the program.
You can, however, have references selected that are not used in the current project. This should be avoided, because when Visual Basic resolves a reference, it looks through all of the available (checked) Type Libraries. Having unneeded references selected will slow down the program compilation process.
Note the Priority buttons in the References dialog box. You use these buttons to move the highlighted reference up or down in the list. When Visual Basic comes across a reference to an object in code, it searches the available Type Libraries in the order they are listed in the References list. In the unlikely event that two or more objects have the same name, Visual Basic will use the one it finds first.
Creating And Using Classes
One of the ways that Visual Basic lets you implement software components is by means of classes. A class provides both data storage and code self-contained in a reusable module. When properly designed, a class isolates you, the programmer, from all of its inner workings. You can simply use it without worrying about what is going on inside. Once you have created a class, you can reuse it in any and all of your Visual Basic projects. You implement a class in Visual Basic by means of a class module. The type of class were talking about now cannot present a visual interface to the userit is code and data only. Other types of Visual Basic classes do provide a visual interface, and we will get to them in subsequent chapters.
TIP: Classes And Objects
What is the relationship between a class and an object? A class can be thought of as a blueprintthe plans for something. An object, on the other hand, is something built, based on those blueprints. You cant actually use a class, just like you cant drive a blueprint for a car. Once you have the blueprint, however, you can build as many objects as you like. In Visual Basic, an object is said to be an instance of the class it is based upon.
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:
ZL3 06 02PRAWO WYKLAD VII 06 02 2011 1D 06 02 01 PRZEPUSTY POD ZJAZDAMIZL1 06 02egzamin 06 02 0606 02 S1 W Technologia informacyjna nowe06 02więcej podobnych podstron