what is the equivalent method in VB.NET 2008 for printer.print in VB6
thanks,
Printable View
what is the equivalent method in VB.NET 2008 for printer.print in VB6
thanks,
There is no easy equilivalent. You have to do all the printing yourself. Use the PrintDocument control/object which will give you the "canvas" on which to print.
thx RD
I already explore PrintDocument Object, it seem need File as an input while Printer.Print just directly print it
Printer.Print is a VB 6 method and the whole print architechure in .NET is completely different. You will not find a managed code colution as simple as Printer.Print ;)
If you are migrating a VB6 solution that uses Printer.Print then I'd suggest adding the Microsoft Visual Basic Power Packs 3.0 which enables straigh-forward Printer.Print type code.
However for a new application I would recommend using the .NET framework printing methods as they are far far far more powerful than Printer.Print - there is a beginners guide that I wrote here...
I would strongly advise against using utilities or packs that allow the use of legacy VB 6 code in .NET as you will never learn as much or be able to take advantage of the power of the framework.
i agree with RD,
if still want to use Classic then don't use .NET :D but thanks for the info Merrion, i will keep it in mind
You will not find a managed code colution as simple as Printer.Print -> yes, very hard to understand at first but i come up with a solution, not try print yet but it found the Default Printer
Code:Dim oPrintDocument As New PrintDocument
AddHandler oPrintDocument.PrintPage, AddressOf PrintDocument_PrintPage
Private Sub PrintDocument_PrintPage(ByVal sender As Object, ByVal ev As PrintPageEventArgs)
' Create font and brush.
Dim drawFont As New Font("Arial", 10)
Dim drawBrush As New SolidBrush(Color.Black)
' Create point for upper-left corner of drawing.
Dim drawPoint As New PointF(150.0F, 150.0F)
' Draw string to screen.
ev.Graphics.DrawString("TESPRINT", drawFont, drawBrush, drawPoint)
End Sub ' PrintDocument_PrintPage