Solved

printing in vb.net

Posted on 2011-09-13
4
309 Views
Last Modified: 2013-05-03
Hello All!

What's the equivalent to

Printer.print "Hello World" & vbcrlf
Printer.print "I am here!"

from VB6 in VB.NET?

Thanks!
0
Comment
Question by:pvg1975
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
kbirecki earned 500 total points
ID: 36533526
0
 

Author Comment

by:pvg1975
ID: 36533603
Great solution! Thanks!
Private Sub Button11_Click_1(sender As System.Object, e As System.EventArgs) Handles Button11.Click
        Dim prn As New Printing.PrintDocument
        prn.PrinterSettings.PrinterName.ToString()
        AddHandler prn.PrintPage, AddressOf Me.PrintPageHandler
        prn.Print()
        RemoveHandler prn.PrintPage, AddressOf Me.PrintPageHandler

    End Sub
    Private Sub PrintPageHandler(ByVal sender As Object, ByVal args As Printing.PrintPageEventArgs)
        args.Graphics.DrawString("HelloWorld With A Printer", New Font("Arial", 20, FontStyle.Bold), Brushes.Black, 150, 125)
    End Sub

Open in new window

0
 
LVL 11

Expert Comment

by:kbirecki
ID: 36533604
Glad it worked for you!  Thanks for the points.
0
 

Expert Comment

by:Larry Biederman
ID: 39135930
Hi pvg1975,

Well, sir, that works perfectly!
Quick question before I award you all the points:

Is this the best, shortest syntax just to dump variables etc to paper?
Can this also be used to dump to a screen?

Thanks, Lbiederman
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VS.net 2010 11 48
vb.net help 4 34
Error message when using PrintSocket.Send 7 18
VB.net Invalid Cast From 'Enum' to 'DateTime' Couldn't store <Null> in oDate Column 4 31
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question