Teach Yourself

VISUAL BASIC® 5 in 24 Hours

Acknowledgments

Sams Publishing makes the best books possible. The reason is solely that it has good people, who shine above all the rest. The author-editor relationship is often a distant one, but I am so very grateful that the people at Sams shorten that distance. The editors are my friends and I'm glad.

Fran Hatton and Kitty Jarrett have gone above and beyond their calls of duty. This book is good because of them, not me. In addition, Dean Miller deserves my thanks over and over because of the jobs he passes along to me.

My technical editor, Robert Wasserman, had quite a job when he took on this project. My writing makes any technical editing challenging, but Robert stayed on the ball the entire book. Other editors and staff at Sams who produced this book are also responsible for this book's excellence, and I alone am responsible for any problems if there are any.

Mr. and Mrs. Bob and Cheryl Enyart continue to improve my life with our friendship. Rarely can one have friends who challenge, teach, and love as much as the Enyarts, and I'm so very grateful for them in my life.

My lovely and gracious bride, Jayne, keeps smiling, waiting, and supporting while I bury my head in a project. As always, thank you, my lovely one. My thanks also go to Dad and Mom, Glen and Bettye Perry, who are my biggest fans. I love you all.

--Greg Perry

About the Author

Greg Perry is a speaker and writer on both the programming and the applications sides of computing. He is known for his skills at bringing advanced computer topics down to the novice's level. Perry has been a programmer and trainer since the early 1980s. He received his first degree in computer science and then a master's degree in corporate finance. Perry is the author of more than 40 computer books, including Absolute Beginner's Guide to Programming, Teach Yourself Windows 95 in 24 Hours, Absolute Beginner's Guide to C, Teach Yourself Office 97 in 24 Hours, C Programming in 12 Easy Lessons, and Visual Basic 4 Starter Kit. He also writes about rental-property management, loves to travel, and helps produce a nationally syndicated television show.

Tell Us What You Think!

As a reader, you are the most important critic and commentator of our books. We value your opinion and want to know what we're doing right, what we could do better, what areas you'd like to see us publish in, and any other words of wisdom you're willing to pass our way. You can help us make strong books that meet your needs and give you the computer guidance you require.

Do you have access to CompuServe or the World Wide Web? Then check out our CompuServe forum by typing GO SAMS at any prompt. If you prefer the World Wide Web, check out our site at http://www.mcp.com.

If you have a technical question about this book, call the technical support line at 317-581-3833.

As the publishing manager of the group that created this book, I welcome your comments. You can fax, e-mail, or write me directly to let me know what you did or didn't like about this book--as well as what we can do to make our books stronger. Here's the information:

Fax: 317-581-4669

E-mail: programming_mgr@sams.mcp.com

Mail: Greg Wiegand Sams Publishing
201 W. 103rd Street Indianapolis, IN 46290

Introduction

You probably are anxious to get started with your 24-hour Visual Basic course. Take just a few preliminary moments to acquaint yourself with the design of this book, which is described in the next few sections.

Who Should Read This Book

This book is for programmers and would-be programmers who want to learn Visual Basic as quickly as possible without sacrificing the foundation necessary to master the language. Visual Basic is a product one can use at many levels. Newcomers who have never programmed can create a complete working Windows program in less than two hours, as this book demonstrates. Those who have programmed in other languages will appreciate Visual Basic's design, which makes creating a Windows program more like designing a screen with a mouse-driven art program.

This book teaches Visual Basic in several levels. You will quickly begin creating applications by following simple examples. These applications will be fully working Windows applications with all the usual user-interface controls such as command buttons, labels, and text boxes.

Once you become familiar with building the program's user interface, you can start honing your programming skills by learning the actual Visual Basic programming language. Fortunately, learning Visual Basic's programming language is much easier than learning others, such as C++.

As long as you are familiar with Windows, you can create applications with Visual Basic. You don't have to be a Windows expert, but you should feel comfortable working with menus, the mouse, and the Windows interface. If you've opened, closed, and resized windows, you surely have the skills necessary to create your own Visual Basic applications.

This 24-hour course teaches Visual Basic 5, the latest and greatest Visual Basic incarnation. Visual Basic 5 requires Windows 95 or Windows NT 4.0. The Windows 95 interface introduced in Windows 95 and that now appears in NT makes working within a windowed environment enjoyable.

What This Book Will Do for You

Although this is not a reference book, you'll learn virtually everything a beginning and intermediate Visual Basic programmer needs to know to create usable, powerful, and fun applications with Visual Basic. There are many advanced technical details that most programmers will never need, but this book does not waste your time with them. I know that you want to get up-to-speed with Visual Basic in 24 hours, and this book fulfills this goal without sacrificing the quality of your skill set.

This book presents both the background and the theory that a new Visual Basic programmer needs. In addition to the background discussions, this book is practical and provides tons of step-by-step tasks that you work through to create Visual Basic applications. The tasks start simple and then add details as you move from hour to hour.

Can This Book Really Teach Visual Basic in 24 Hours?

Yes. You can master each chapter in one hour or less (by the way, chapters are referred to as "lessons" or "hours" in the rest of the book). Although some lessons are longer than others, the material is balanced. The longer chapters contain several tasks, and the shorter chapters contain background material. The balance provided by the tasks, background, and insightful explanations and tips makes learning Visual Basic using this book fresh at every page.

What You Need

This book assumes that you have a Windows 95-compatible computer with Windows 95 installed. In addition, you need Visual Basic 5.0 installed. As long as you have the hardware to install both Windows 95 and Visual Basic 5, you have everything you need to use this book and to learn Visual Basic programming.

Conventions Used in This Book

The lessons highlight new terms as they appear. There is a question-and-answer section at the end of each lesson to reinforce ideas. In addition, the lessons reinforce your learning further with quiz questions and exercises.

This 24-hour course also uses several common conventions to help teach the programming topics. Here is a summary of the typographical conventions:

For CounterVar = StartVal To EndVal [Step IncrementVal]

   Block of one or more

      Visual Basic statements

Next CounterVar

In addition to typographical conventions, the following special elements are included to set off different types of information to make them easily recognizable:


NOTE: Special notes augment the material you are reading in each hour. They clarify concepts and procedures.



TIP: You'll find numerous tips that offer shortcuts and solutions to common problems.



WARNING: The warning sections warn you about pitfalls. Reading them will save you time and trouble.

Enough! Time Is Ticking!

Want to master Visual Basic? Turn the page.