Solved

printing in vb.net

Posted on 2011-09-13
4
307 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

895 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now