How to Print to a Specific Printer in VB.NET

Written by jim campbell
  • Share
  • Tweet
  • Share
  • Email

The VB.NET "PrintDocument" class lets you define a document and printer, so you can send a print job to a printing device on the computer or on the network. You define the printer to which you want to print in the "PrinterSettings" property. If you do not define a printer, VB.NET prints to the default printer set up in the Windows system.

Skill level:


  1. 1

    Right-click the VB.NET SLN file on your computer, click "Open With" and double-click the "Visual Studio" icon to load the VB.NET project in the work space.

  2. 2

    Double-click the code file you want to use in "Solution Explorer." Scroll down the file to the function you want to use to print a document.

  3. 3

    Define a "StreamReader" variable:

    Dim stream As StreamReader

    stream = New StreamReader("C:\file.txt")

    This variable imports all text and layouts from a file to print to a printer. Replace "C:\file.txt" with any location and file you want to print.

  4. 4

    Set up the printer using the printer name set up in the Windows system:

    Dim printer As New PrintDocument()

    printer.PrinterSettings.PrinterName = "HP Deskjet"

    Replace the "HP Deskjet" name with the name of the printer on the computer.

  5. 5

    Use the "Print" function to print the document by adding the following code :


Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.