Home > Store

Nitty Gritty Visual Basic 6

Register your product to gain access to bonus material or receive a coupon.

Nitty Gritty Visual Basic 6

Book

  • Sorry, this book is no longer in print.
Not for Sale

About

Features

Description

  • Copyright 2002
  • Dimensions: 7-3/8x9-1/4
  • Pages: 368
  • Edition: 1st
  • Book
  • ISBN-10: 0-201-75876-8
  • ISBN-13: 978-0-201-75876-4

 This book deals with Visual Basic, a programming language which is increasingly gaining ground in the face of its competitors. Addison-Wesley Nitty Gritty Visual Basic 6 offers introductions to VB, looking at the fundamentals of this language. For the more advanced programmer, this book enhances skills such as program development techniques, error handling and debugging and database access using ADO.  

Sample Content

Table of Contents

Preface 11

P.1 The book's conception 13

P.2 Typographic conventions 16

P.3 Where you can find help and further information 17

Part I - Start up!
Getting started with Visual Basic 21

1 Visual Basic, VBA and VBScript 23

1.1 What are Visual Basic, VBA and VBScript? 23

1.2 Programming in Visual Basic 24

1.3 What can Visual Basic do? 25

1.4 The editions of Visual Basic 27

1.5 Service Pack 4 and other updates 27

2 Introduction to VB 29

2.1 Object orientation in VB 29

2.1.1 What is an object? 29

2.1.2 What is a class? 33

2.2 Starting Visual Basic: the different project types 33

2.3 The development environment 35

2.3.1 Overview of the windows 35

2.3.2 Fundamentals of writing program code 38

2.4 The Visual Basic project 42

2.5 Important options 45

2.5.1 Options of the development environment 45

2.5.2 Compiling options 47

2.6 A first Visual Basic application 48

Part II - Take that!
Programming in Visual Basic 55

3 Fundamentals of the VBA language 57

3.1 Modules 57

3.2 Statements, expressions and operators 59

3.3 Declaring variables 67

3.3.1 Implicit declaration 67

3.3.2 Explicit declaration 67

3.4 The data types 72

3.4.1 The VBA data types 73

3.4.2 The Reddik naming convention 78

3.4.3 Static arrays 83

3.4.4 Dynamic arrays 84

3.4.5 Initializing arrays 86

3.4.6 Allocation of arrays 86

3.4.7 Structures 86

3.4.8 Symbolic constants 87

3.4.9 Enumerations (Enums) 88

3.5 Loops and branches 90

3.5.1 Conditional branches 90

3.5.2 "Branch" functions 93

3.5.3 Unconditional branches 94

3.5.4 Loops 94

3.5.5 Exiting a program block 98

3.5.6 The With statement 99

3.6 Procedures and functions 99

3.6.1 Declaring procedures and functions 100

3.6.2 Call by Value and Call by Reference 102

3.6.3 Functions that return objects 103

3.6.4 Functions that return arrays 104

3.6.5 The passing of arrays 104

3.6.6 Parameter arrays 105

3.6.7 Optional arguments 106

3.6.8 Recursion 107

3.7 Conditional compilation 108

3.8 Working with objects 109

3.8.1 Class libraries 112

3.8.2 Collections 113

3.8.3 Your own collections using dictionary objects 114

4 VBA functions and VB objects 121

4.1 The object browser 121

4.2 File and folder functions 123

4.3 String functions 127

4.3.1 Extracting partial strings and shortening strings 127

4.3.2 Compare strings and search for partial strings 127

4.3.3 Replacing strings 131

4.3.4 Conversion and creation of strings 132

4.3.5 Separating and joining strings 133

4.3.6 The left-over Len function 134

4.4 Formatting functions 135

4.5 Date functions 138

4.6 Arithmetic functions 141

4.7 Conversion functions 141

4.8 Information functions 143

4.9 Interaction functions 144

4.10 Functions for output and input 146

4.10.1 The MsgBox function 146

4.10.2 The InputBox function 149

4.11 The VB objects 149

5 Controls and forms 153

5.1 Standard controls, ActiveX and windowless controls 153

5.2 Common elements of all controls 155

5.2.1 The most important com

Preface

This is my first foreword, which tells you that this is also my first book. I myself have never read a foreword before. Now that I have written one I can see the reason for it: I want to give you an overview of this book and show you what possibilities are open to you when it comes to the Internet.

This book deals only with Visual Basic, my favorite programming language which is increasingly gaining ground in the face of its competitors. This begs the question perhaps as to why Visual Basic has become such a popular programming language in the meantime.

With Visual Basic you can do everything conceivable for Microsoft operating systems. Visual Basic supports the latest Microsoft technologies so that your programs are always up to date. You can usually download state-of-the-art technologies directly from the Microsoft website, install and (with a little know-how) insert them into Visual Basic.

With Visual Basic you can produce not only normal Windows applications but also (with some limitations) do object-oriented programming, access almost any databases and other data sources, develop reusable components and controls, create real multilayer applications, write multithreading components and create multimedia and Internet applications. So just about everything is possible!

OK, so some features are missing in the current Version 6, for example real inheritance, but firstly you will probably get by best with those features available for standard applications and secondly the new Version 7 adds clear finishing touches.

Visual Basic is not all about advantages and I do not wish to keep silent about the disadvantages. One of the most serious of these is that Microsoft with Visual Basic still carries around a lot of padding (you could say garbage), which was inherited from the original version of (Microsoft-DOS)Basic. Another disadvantage is that programming of the new features for the current VB versions was very 'sloppy' and favors the user with a lot of inconsistencies and bugs. Unfortunately Microsoft to date has set a lot of store by the development of new features and has hardly, if at all removed the bugs in the old ones. VB.NET adds the finishing touches here. Microsoft has committed each developer in the VB team to develop no more new features but firstly to remove errors in the current ones if they receive reports of more than 25 (it begs the question of how development was done previously).

But I do not wish to join in the chorus of other people in making out that Visual Basic is bad. If you know the pitfalls, VB is a wonderful, fast and simple programming language. I have got used to simply ignoring the defective or bad programmed features I know and, where necessary, using other components (bought or as Freeware mostly from the Internet). You will certainly read some criticisms in this book, but you will find rather more that most features are described positively (I have simply not bothered to describe features which are not going to be used). So that you avoid the pitfalls, I do of course describe the problems as well and usually provide a solution.

And to those programmers who believe C program to be considerably faster, suffice it to say that the VB compiler utilizes the Microsoft C compiler at the lowest level.

As you may have already noticed, this book is a paperback. Therefore space available is terribly limited compared with a "proper" book. The Nitty Gritty series as its name suggests gets down to the nitty-gritty so everything has to be scaled down. I am working on the basis therefore that you understand the basics of programming and have a sound knowledge of Windows. On this assumption you can learn with the help of this book the most important features and components of Visual Basic. Since Visual Basic in the meantime has become a very powerful programming language, I cannot describe everything in approximately 400 pages. The book does not deal with some of the features and components which are in my view less important (unfortunately including OOP).

Information and tips and tricks

The individual sections of the book are usually laid out so that a description telling you how to use a particular feature in practice follows a general introduction. Then there is an overview in table format showing you the most important elements. The conclusion is frequently a section in which I describe tips and tricks for that particular topic.

The contents of the book

So that you get an overall view of the topics included in the book, I am listing them here, chapter by chapter:

Chapter 1 gives you an overview of Visual Basic and VBA, the programming language used in Visual Basic.

Chapter 2 introduces you to programming with Visual Basic (without however explaining the fundamentals of programming) and gives an overview of the possibilities open to you.

Chapter 3 describes in great detail how you program with VBA (variables, loops, branches, functions, etc.).

Chapter 4 explains the functions of the VBA library and describes the few objects predefined in VB.

In Chapter 5 there is a description of the correct procedure for dealing with standard controls, the most important ActiveX controls and windowless controls using forms and menus. Because of the large number and complexity of some ActiveX controls, not all ActiveX elements are described in this chapter.

Chapter 6 explains, in my view, the most important program development technologies, with some topics, such as graphics and printing, and database programming only being described in later chapters.

Chapter 7 concentrates on the treatment of run-time errors, debugging and
testing an application.

Chapter 8 deals with the output of text and graphics on forms or the printer using VB graphics methods and, by way of example, the Windows GDI functions.

Chapter 9 explains how to deal with FileSystemObjects to access the file system and to read and write text files.

Chapter 10 introduces you to working with databases. This chapter emphasizes the fundamentals of data access with ActiveX Data Objects and leaves untouched many "Quick and Dirty" Visual Basic database features.

Finally, Chapter 11 shows you how to create an installation version out of your VB project that can be installed on other computers.

What the book does not include

Of course you should also know what topics are not described in the book. For this reason I am listing them here.

What is missing in the fundamental functionality area
  • The financial-mathematical VBA functions
    The financial-mathematical VBA functions are very complicated. In addition I have absolutely no idea about financial mathematics (which is probably why my bank account is always empty).
What is missing in database programming
  • The database tools of the development environment
    The development environment contains tools which display the structure and content of a database and even allow you to edit these (amongst other things data view, menu query and diagrams).
  • Database connections to the Data Environment
    The data environment has interesting potential because you can create connections very quickly to databases and generate queries. However I have always avoided the Data Environment up to now because initializing the run-time is difficult and you lose control of your database connection. I have not described the Data Environment in this book.
  • The utilization of binding controls to a database (the book conveys only the fundamental principles)
    I only describe the basics for binding controls to data sources in this book.
  • Designing reports using the Integrated Report Generator or the Crystal Reports components
    The Integrated Report Generator, which can do hardly anything really well, is brought to its limits very quickly when it comes to printing reports. Crystal Reports is the considerably better alternative here. Unfortunately Seagate no longer supplies the Crystal Reports Designer component free of charge, which up to Crystal Reports 6 had been free. Nevertheless on the website I describe how you can produce reports using the Integrated Report Generator and the Crystal Reports component.
  • The query language SQL
    SQL is described over and over again in many programming books. I think however this extensive language is better described elsewhere to leave room for the actual programming language features. Therefore you will not find SQL described in this book.
What is missing when it comes to special technologies
  • Multimedia programming
    You can achieve simple multimedia effects with some VB controls. If you want to write good multimedia programs, you cannot escape DirectX-API.
  • Remote control of Word, Excel and co
    Remote control of Word, Excel and co using COM automation is a very interesting process, in which you can borrow the functionality of these applications for your application without the user knowing anything about it. So I can print my invoices in my accountancy program using a Word document template, which I open in Word from my VB program and which I describe in Word.
Object-oriented programming (OOP)

Object-oriented programming, i.e. the production of intrinsic classes and based on this the production of a listing of classes, class hierarchies, COM (component object model) components and ActiveX controls, is omitted from this book. At first I had planned to include some fundamental information, but this had to be removed again because of lack of space. In addition this information would probably have been too incomplete.

Internet programming

Internet programming is omitted from this book. Visual Basic alone is also insufficient to write good Internet applications. I am in the process of writing a book especially about Internet programming with ASP and Visual Basic in the Nitty Gritty series. Along with buying this book I recommend "Microsoft Active Server Pages" by Jörg Krause.

I hope I have made the overview of this book easier for you.




0201758768P10172001

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020