Groups | Blog | Home
all groups > vb.net upgrade > november 2003 >

vb.net upgrade : Printing-Codes Conversion from VB 6.0 to VB.NET


Samuel Lee
11/12/2003 5:09:44 PM
Could anyone convert the following vb 6.0 codes into vb.net version?


'************************************************************************
'** Button to print a sales receipt - spool print data to receipt printer
'************************************************************************
Private Sub cmdPrintReceipt_Click()
Printer.CurrentX = 0: Printer.CurrentY = 0
Printer.FontName = "Arial"

'Print header
Printer.FontBold = True
Printer.CurrentX = 60
Printer.Print "SALES HEADER"
Printer.FontBold = False

Printer.CurrentX = 90
Printer.Print "Sales Description"
Printer.Print 'Print blank line

Printer.EndDoc 'End document to print
End Sub


I don't have problem printing receipt in vb 6.0 running on Win98? After I
converted it into vb.net I only manage to print receipt for the first time
on Win98 but I don't have problem on Win2K. I got the following error the
moment I print the second time on Win98.

System.NullReferenceException
Object reference not set to an instance of an object.

This error occurred at MyDoc.Print() where MyDoc is declared as below:

Private MyDoc As New PrintDocument()

Any idea?

hirf-spam-me-here NO[at]SPAM gmx.at
11/12/2003 5:57:10 PM
* "Samuel Lee" <neosamz@hotmail.com> scripsit:
[quoted text, click to view]

Please post the complete printing code.

You will find a sample application about printing here:

<http://www.mvps.org/dotnet/dotnet/samples/printing/downloads/PrintFramework.zip>

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

AddThis Social Bookmark Button