Visual Basic 4 in 12 Easy Lessons vel4fm.htm

Previous Page TOC Next Page



What's New In This Edition


In the second edition of this best-selling book, you'll find dozens of areas with new or updated coverage, including

Acknowledgments


Mega-thanks go from me to the editorial staff at Sams Publishing. Their excellence and caring go far beyond the usual publishing standards. If readers find good things in this book it is because of the people at Sams. If readers find not-so-good things, I take full responsibility.

The technical editor, John Charlesworth, had the difficult job of turning my words into accurate text and I thank him so much. In addition, I want to thank the fine production staff at Sams Publishing who care more about the final product than any other staff in the world. One particular member of Sam's fine editorial staff who worked harder than the author is Katherine Ewing. Somehow she made a book out of my random words. I appreciate your eagle eyes, Kathy!

As always, my beautiful bride Jayne and my parents Glen and Bettye Perry are my three favorites in the world.

About the Author


Greg Perry has written more than 40 books and continues to take computer topics and bring them down to the beginner's level. Perry has been a programmer, trainer, and speaker for the past 18 years. He received his first degree in computer science and then a master's degree in corporate finance. Among the other books he has written are Teach Yourself Object-Oriented Programming With Visual C++, QBasic Programming 101, Absolute Beginner's Guide to Programming (all Sams Publishing), and The Complete Idiot's Guide to Visual Basic (Alpha Books). In addition, he has published articles in several publications, including Software Development, Access Advisor, PC World, and Data Training. In his spare time, he manages rent houses, drinks gallons of Snapple, participates in local political campaigns, and constantly tries to improve his fractured Italian.

Introduction


The book you hold offers something you may not have encountered before. Whereas other books might teach you Visual Basic 4.0, this book includes a working Visual Basic 4.0 programming system on a CD-ROM to accompany the text's tutorial of the language. With this book, there is literally nothing else to buy (except, of course, Windows 95 and the computer)! Microsoft's Visual Basic programming system turns your computer into a Visual Basic programming powerhouse with which you can write Windows 95 applications. The CD-ROM that comes with this book also includes all the book's programming projects, code listing, as well as answers to all the exercises at the end of each unit.

Despite the great CD-ROM included, this book would be worthless if it didn't teach Visual Basic. Visual Basic 4.0 in 12 Easy Lessons begins at the beginning, assuming that you don't know Visual Basic or any of the BASIC-like languages that preceded Visual Basic. You'll be learning how to program, perform input and output, how to work with disk files, and draw graphics through Visual Basic programs.

Visual Basic is one of the most successful Windows programming tools on the market today and for good reason. Whereas other Windows programming languages require steep learning curves, Visual Basic lets you design and write complete Windows applications without a lot of effort and tedium.

Who Should Use This Book


Visual Basic 4.0 in 12 Easy Lessons is aimed primarily at beginning programmers who either have never programmed or who have never seen a Visual Basic program before. Text, questions, exercises, and numerous program listings are aimed at both beginning programmers and those programmers new to Visual Basic.

If you already program but have never tackled Visual Basic or Windows programming, this book is right for you because it teaches more than just the language. This book attempts to teach you how to program correctly, concentrating on proper coding techniques in addition to the Visual Basic language.

This Book's Philosophy


Visual Basic 4.0 in 12 Easy Lessons extends the traditional programming textbook tutorial by offering all the text and language syntax needed for newcomers to Visual Basic. It also offers complete program examples, exercises, questions, tips, warnings, notes, and, of course, a full-featured Visual Basic programming system.

This book focuses on programming correctly by teaching structured programming techniques and proper program design. Emphasis is placed on a program's readability rather than on "tricks of the trade" code examples. In this changing world, programs should be clear, properly structured, and well documented.

The format of this book, 12 lessons with two units per lesson, was planned to give you the most out of each sitting. You'll find that you can master each lesson in one evening taking a short break between the lesson's two units. At the end of the lessons are projects. They contain programs that use the lesson's key points and the also feature a unique line-by-line description of the program's code.

A Note to the Instructor


If you're an instructor using this teaching system for your class, you'll find that its inclusion of the Visual Basic language lets the entire class participate on the same level, using the same language version for their programs. When you demonstrate the writing, editing, and debugging techniques, you'll know that your students will be using the same version of the Visual Basic language that you use in class.

Each unit offers numerous questions and exercises that provide a foundation for classroom discussions. The answers to all the questions and exercises are on the enclosed CD-ROM. In addition, each unit contains one or more "extra credit" programming exercises that you can assign as homework. The answers to the extra credit exercises don't appear on the CD-ROM.

The typical semester class is divided into 15 or 16 weeks of study. A useful lesson plan that incorporates this book would spend one week on each lesson, with four exams every four weeks. Each lesson contains two units, and you can easily cover one unit in a single classroom sitting.

Because Visual Basic 4.0 in 12 Easy Lessons becomes a part-time teacher, questioning and guiding the student as he or she reads and learns, you can spend more classroom time looking at complete program examples and exploring the theory of Visual Basic instead of taking the time to cover petty details.

Overview


Here is an overview of this book, giving you a bird's-eye view of where you're about to head.

Lesson 1: Welcome to Visual Basic

This lesson explains what programming is all about and provides a brief history of programming languages. The lesson presents an overview of Visual Basic's advantages over other languages and explains the event-driven nature of Windows 95 programs. By the second unit, you will be working with the Visual Basic environment.

Lesson 2: Visual Basic Programs

This lesson familiarizes you with the format of Visual Basic programs. Once you master this lesson, you'll be able to distinguish all the various parts of a Visual Basic program that go together to produce the final working application the user eventually sees. In this lesson, you will create your first Visual Basic application.

Lesson 3: Getting Down to Business

Being a Windows-development system, Visual Basic relies heavily on graphical screen objects that you, the programmer, manage as you write programs. This lesson teaches you how to place the graphical objects on the user's window to create controls with which the users of the program will interact.

Lesson 4: Data Basics

Visual Basic supports all kinds of data. This lesson teaches you about Visual Basic variables, data, and controls. You must understand the various data types possible in Visual Basic before you can work with data. You'll see how Visual Basic supports both numeric and character data as well as learn the mathematical operators that Visual Basic recognizes.

Lesson 5: Gaining Control

The messages that you place in programs that help you update those programs later are called remarks. It's vital that you learn the importance of proper program documentation early. Of course, interacting with users is extremely important also, and message boxes are Visual Basic's primary means for asking the users questions and getting answers. In addition to the remark and message box processing, this lesson explains the looping elements of the language. By repeating sections of a program, the program can perform multiple calculations on a large series of data values.

Lesson 6: Combining Code and Controls

Now that you've mastered most of Visual Basic's user interaction controls, this lesson takes you the next step of the way by demonstrating how to create lists of data and controls that greatly improve the power of the programs that you write. Once you introduce lists into a program, the checkboxes and option buttons give your users the means by which they can interact with those lists of data.

Lesson 7: Functions and Dates

Visual Basic supplies a large number of math, character, date, and time functions. These functions eliminate tedious coding on your part that you would normally have to do. By providing pre-written function routines, Visual Basic lets you concentrate on the user-specific portions of the applications that you write.

Lesson 8: Modular Programming

Once you've mastered Visual Basic's built-in function routines, it's time to learn how to write your own functions that you can add to your own growing library of Visual Basic routines. As you write more and more Visual Basic programs, you will write routines that you can use in more than one program. Thus, as you build your Visual Basic library of programs, you'll be able to reuse parts of programs that you've already written and speed all subsequent program development.

Lesson 9: Extending Data and Programs

Your computer would be too limiting if you couldn't store data to the disk and load that data back into your programs. Disk files are required by most real-world applications. The units in this lesson describe how Visual Basic processes disk files and teaches you the fundamental principles needed to effectively work with disk files.

Lesson 10: Making Programs "Real World"

By adding menus and toolbars to your programs, you give additional control to the users of your applications. Most Windows programs support the use of menus and toolbars. In addition to adding menus and toolbars, this lesson also teaches you how to track timer controls so that you can write real-time programs that respond to the passing of time.

Lesson 11: Spruce Up your Programs

Visual Basic supports the use of printed reports that you can create with the commands that you learn in this lesson. Not only will the addition of the printer add to your program power, but you can also add spice to your programs by drawing graphics on the program screens that you create to offer eye-catching pictures that capture the user's attention.

Lesson 12: Getting Exotic

This lesson extends your fundamental knowledge of the Visual Basic programming system by teaching you how to work with additional user controls called scroll bars and grid controls. Scroll bars give users visually-moving controls over data values and input. Using the grid, users can see tables of data that you present in a spreadsheet-like format. You'll also learn ways to respond to mouse movements and clicks. By this lesson's end, you will have mastered most of Visual Basic's fundamental programming techniques. Due to the complex nature of programs that you will begin to write by this lesson, the book ends with a discussion of Visual Basic's interactive debug sessions that shows you how to eliminate problems that might creep into the programs that you write.

This Book's CD-ROM


This book contains the Visual Basic programming system called the Visual Basic Working Model. Visual Basic is made by Microsoft, a world-famous company known for its Windows 95 operating environment. The Visual Basic Working Model programming system comes with an integrated editor, debugger, and program designer with which you can write fully-working Windows 95 programs.

***Begin Note***



Note: The second unit of Lesson 1 explains how to install the Visual Basic Working Model programming system on your computer.

***End Note***

The CD-ROM also contains all the code in all of this book's programs. In addition, the CD-ROM contains answers to all review questions and exercises at the end of each unit, except for the extra credit problems. The answers are organized by lesson and are in a directory named \ANSWERS.

Conventions Used in This Book


This book uses the following typographic conventions:

The following items also appear throughout this book:



Definition—Definitions of new terms often appear in the paragraph in which the term first appears.

***Begin Note***



Note: When further thought is needed on a particular topic, the note icon brings extra information to your attention.

***End Note***

***Begin Tip***



Tip: A tip shows you an extra shortcut or advantage possible with the command you just learned.

***End Tip***

***Begin Warning***



Warning: Sometimes you must take extra care when trying a particular command or function. Warnings point out dangers before you encounter the dangers yourself.

***End Warning***

***Begin Sidebar***



Sidebar: In addition, you'll find several sidebars with useful information that is related to the topic at hand.

***End Sidebar***

***begin sidebar***



Concept: Concepts, located at the beginning of each major section, provide a succinct overview of the material in that section.

***end sidebar***

***begin sidebar***



Review: Reviews, which appear at the end of each major section, recap the material you learned in that section.

***end sidebar***

This icon provides a description of a subsequent program listing.

Input: An input icon marks a program listing that demonstrates the major concepts from the section you just finished.

Output: This icon accompanies a typical output of the program or program screen.

Analysis: A detailed description of the program appears after the output.

Previous Page Page Top TOC Next Page