Sams Teach Yourself Visual Basic 6 in 24 Hours
- Table of Contents
- Copyright
- About the Author
- Acknowledgments
- Introduction
- Who Should Read This Book
- What This Book Will Do for You
- Can This Book Really Teach Visual Basic in 24 Hours?
- What You Need
- Files on the Visual Basic Distribution CD-ROM
- Conventions Used in This Book
- Enough! Time Is Ticking!
- Part I: Introducing Visual Basic
- Hour 1. Visual Basic at Work
- Hour 2.Analyzing Visual Basic Programs
- Hour 3.Controls and Properties
- Hour 4.Examining Labels, Buttons, and Text Boxes
- Part II: Coding the Details
- Hour 5.Putting Code into Visual Basic
- Hour 6.Message and Input Boxes
- Hour 7.Making Decisions
- Hour 8.Visual Basic Looping
- Part III:Putting Code to Work
- Hour 9.Combining Code and Controls
- Hour 10.List Boxes and Data Lists
- Hour 11.Additional Controls
- Hour 12.Dialog Box Basics
- Part IV:Programming with Data
- Hour 13.Modular Programming
- Hour 14.Built-In Functions Save Time
- Hour 15.Visual Basic Database Basics
- Hour 16.Printing with Visual Basic
- Part V:Sprucing Up Programs
- Hour 17.Menus and Visual Basic
- Hour 18.The Graphic Image Controls
- Hour 19.Toolbars and More Graphics
- Hour 20.Writing Correct Applications
- Part VI:Advancing Visual Basic Applications
- Hour 21.Visual Basic and ActiveX
- Hour 22.Object Basics
- Hour 23.Distributing Your Applications
- Hour 24.Online Visual Basic
- Part VII:Appendixes
- Appendix A.Operator Precedence
- Appendix B.Answers
- Appendix C.Using the CD-ROM
Introducing Printing
Surprisingly, no Printer control exists. Unlike most things in Visual Basic, sending output to the printer can be a tedious process. Printing requires that you send a fairly long list of instructions to your printer that describe exactly the way the output is to look. As easily as Visual Basic enables you to add and manage controls, one would have thought that the printing could be made easier.
Despite the tedium sometimes associated with printing, you will soon see that you can control every aspect of printing, including the font of individual characters that your application sends to the printer. The tedious control needed for printing provides pinpoint accuracy that lets you control all printing details.
The Windows print spooler, also known as the print queue or the printer subsystem, controls all printed output in Windows.
When your application sends output to the printer, Windows intercepts those printer commands. Rather than sending output directly to the printer attached to your computer, Visual Basic actually sends printed output to the Windows print spooler.
The print spooler determines how all printed output from all Windows programs eventually appears. Therefore, when your Visual Basic application attempts to send printed output directly to the printer, the Windows print spooler intercepts those commands and might change the output before the printer ever sees it.
The Windows print spooler knows how to communicate with any printer supported by Windows. There are hundreds of different kinds of printers now recognized by Windows, and most of these printers require specialized commands. If every program that you bought had to provide support for every kind of printer that you or your users might own, programs would require even more disk space than they already do. In addition, programs would cost more because each software developer would have to spend time writing the program to produce output onto every kind of printer available.
Rather than require that every software developer support all printers, the Windows print spooler requires that every software developer support only one kind of printed output: the kind required by the Windows print spooler. If the applications that you write need to produce printed output, Visual Basic produces that output in a form required by the Windows print spooler. Figure 16.1 shows that Visual Basic applications send output directly to the Windows print spooler. The Windows print spooler then converts that output into the individual commands needed by whatever printer is attached to the system.
Figure 16.1 Windows intercepts printer output.
Suppose that you had both a laser printer and a color ink-jet printer attached to your computer. Without the Windows print spooler, you would need to provide two sets of printer commands for every Visual Basic application you write. With the Windows print spooler, you need to provide only one generic set of printer output commands. Before running the application, you can use commands available in the Windows print spooler to select one of your two printers. When you run the program, Windows will convert the Visual Basic output into commands needed by whatever printer is selected.
Preparing the User for Printing | Next Section

Account Sign In
View your cart