This documentation is archived and is not being maintained.

How to: Fix Upgrade Errors by Using the Printer Compatibility Library

Visual Studio 2005

The Printer Compatibility library emulates the functionality of the Visual Basic 6.0 Printer object, which enables the Printer code in applications that have been upgraded from Visual Basic 6.0.

To fix Printer upgrade errors

  1. Open the application in Visual Studio.

    If a Visual Basic 6.0 application has not yet been upgraded, opening it in Visual Studio will start the Upgrade tool.

  2. On the Project menu, click Add Reference.

  3. In the Add Reference dialog box, on the .NET tab, click Microsoft.VisualBasic.PowerPacks.Printing.Printer, and then click OK.

  4. In the Code Editor, add the following statement at the top of the module that contains your Visual Basic 6.0 Printer code:

    Imports Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6
    
  5. Add the following code at the top of the procedure that contains Printer code:

    Public Printer As New Printer
    

    Most errors related to the Printer object will disappear from the Error List, and your Printer code should compile and run just as it did in Visual Basic 6.0.

    Note:

    You must manually remove all error or warning comments that appear in the code, but these comments will not prevent the code from compiling. Some warnings may remain in the Task List; frequently these are related to Visual Basic 6.0 Variant types that were upgraded to Object and that can safely be ignored.

    In some cases, code that uses the Circle, Line, or PSet methods will have to be modified before the code compiles. The Visual Basic 6.0 versions of these methods contained parentheses around X/Y pairs in the method signatures. These parentheses must be moved in order for the code to compile in Visual Basic 2005.

    For example, the upgraded Visual Basic 6.0 code Printer.Circle (1000, 1000), 2000 would have to be changed to Printer.Circle (1000, 1000, 2000) in order to compile.

Show: