Printing-Codes Conversion from VB 6.0 to VB.NET

S

Samuel Lee

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top