Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Name 'Printer' is not declared VB6 to .NET

I am upgrading VB6 to .NET after the upgrade I get the compile error:

Name 'Printer' is not declared

My code in VB6 is something like this:

THeight = Printer.TextHeight("#")

What is the correct way to declare a printer in .NET?

Note: I tried to download the printer power pack, but was unable to get it to work.

like image 410
nate Avatar asked Dec 19 '22 10:12

nate


1 Answers

Visual Basic 6.0 had an intrinsic Printer object that you could use without explicitly declaring it. In contrast, the Printer Compatibility library behaves like any other .NET Framework object; you must explicitly declare a .NET Framework Printer object before you can use it.

After you upgrade your project, you could add Printer object like this:

1) On the Project menu, click Add Reference.

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

3) 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

4) Add the following code at the top of the procedure that contains Printer code:

Public Printer As New Printer

like image 82
nate Avatar answered Jan 15 '23 05:01

nate