Export (0) Print
Expand All

Printing Changes for Visual Basic 6.0 Users 

Visual Basic 2005 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 2005, the PrintDocument component replaces the Printer object. Equivalent graphics methods include the DrawString, DrawLine, and DrawImage methods of the Graphics class.

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 2005, the Printers collection is replaced by the PrintDialog control, which provides a standard Windows Print dialog box.

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 no longer supported in Visual Basic 2005.

The results of the PrintForm method vary greatly depending on the screen resolution and the resolution of the printer; it is not the recommended method of printing. If you need to duplicate the functionality of the PrintForm method, you can automate the screen capture capabilities of a third-party graphics tool to capture and print an image of a form.

Print Preview

In Visual Basic 6.0, implementing print preview is only possible through third-party controls. In Visual Basic 2005, 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 2005, 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 2005, 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

Community Additions

ADD
Show:
© 2014 Microsoft