Unsurprisingly, Visual Basic provides us with a Printer
and Printers
object which is available at runtime to all VB apps. The Printers object gives
us information about all the available printers installed on the system. The
Printer object controls all the output to the active printer, and retrieve information
such as the printer name.
First of all, lets look at the basic steps involved in printing in VB. First off, we send all the data we want to print using the Print method. For example, if we wanted to print "Hello", we would call
Printer.Print "Hello"
Each time you call the Print method, your output will move to the next line. So,
Printer.Print "Hello"
Printer.Print "Goodbye!"
would appear as
Hello
Goodbye!
on paper.
If you want to output a new page, you simply call the NewPage method:
Printer.NewPage
Once you have finished outputting the data to the printer, you need to call the EndDoc method:
Printer.EndDoc
Windows will then spool your document to the printer.
Comments