Printing Changes for Visual Basic 6.0 Users

Visual Basic 2008 provides greatly improved support for printing through classes that control the printing of documents, that allow users to modify print settings and choose printers, and that allow print preview.

Conceptual Differences

Printer Object

In Visual Basic 6.0, the Printer object is used for printing; it supports various graphics methods such as Print, Line, and PaintPicture to control what is printed.

In Visual Basic 2008, the PrintDocument component replaces the Printer object. Equivalent graphics methods include the DrawString, DrawLine, and DrawImage methods of the Graphics class.

Note

Visual Basic 2008 has a Printer object that allows upgraded Visual Basic 6.0 Printer code to run without modification. For any new development, you should use PrintDocument.

For more information, see Printer Object for Visual Basic 6.0 Users.

Printers Collection

In Visual Basic 6.0, the Printers collection is used to direct the output of a Printer object to a different printer. The Printers collection contains a list of available printers that match the list displayed in the Windows Print dialog box.

In Visual Basic 2008, the Printers collection is replaced by the PrintDialog control, which provides a standard Windows Print dialog box.

Note

Visual Basic 2008 has a Printers collection that enables upgraded Visual Basic 6.0 Printer code to run without modification. For any new development, you should use the PrinterSettings class.

For more information, see Printers Collection for Visual Basic 6.0 Users.

PrintForm Method

In Visual Basic 6.0, the PrintForm method of a form can be used to send an image of the form to a printer. The PrintForm method is replaced by the PrintForm component in Visual Basic 2008.

In Visual Basic 6.0, implementing print preview is only possible through third-party controls. In Visual Basic 2008, the PrintPreviewDialog control can be used to provide a standard Windows Print Preview dialog box. For more information, see PrintPreviewDialog Control Overview (Windows Forms).

Page Setup

In Visual Basic 6.0, no user interface for page setup is provided. In Visual Basic 2008, the PageSetupDialog control can be used to provide a standard Windows Page Setup dialog box. For more information, see PageSetupDialog Component Overview (Windows Forms).

Printing from A File

In Visual Basic 6.0, printing text from a file requires a considerable amount of code. In Visual Basic 2008, the StreamReader class can be used to pass the contents of a text file directly to a PrintDocument component. For more information, see the Print method of the PrintDocument class.

See Also

Concepts

Printer Object for Visual Basic 6.0 Users

Printers Collection for Visual Basic 6.0 Users

Other Resources

Windows Forms Print Support