Tuesday, July 28, 2015
How to Print to a Specific Printer in VB.NET
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.
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.
Define a 'StreamReader' variable:Dim stream As StreamReaderstream = 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.
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.
Use the 'Print' function to print the document by adding the following code :printer.Print()
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment