Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Need to print to network printer address. i.e. \\par-ps-01\ParZebra

Replacing VB6 code

Open PrinterName For Output As #1
Print #1

Need to convert to VB.NET code. Any help would be appreciated. Thx!!!

PrintLine(1, "^XA^ID*.*^PRE^LH0,0^FS^LL1218^MD0^LH0,0^FS")   ' Print text to file.


What I have tried:

VB.NET

Stremwrite, FileStream, cant figure out how to print directly to network printer..
Posted
Updated 15-Jan-19 11:29am

Printing changed massively (and for the better) in VB.Net - see the article An Absolute Beginner's Guide to Printing in .NET[^] but if you want to use the old syntax / methodology you need to use the Microsoft Visual Basic Power Packs 3.0[^]
 
Share this answer
 
Comments
Maciej Los 15-Jan-19 17:32pm    
5ed!
I have no idea why you want to print some text directly to printer, but... check this: Printing Directly to the Printer in VB.NET[^]

I'd recommend to use PrintDocument Class (System.Drawing.Printing) | Microsoft Docs[^] for printing instead of code shared in above link.

[EDIT]
With reference to MadMyche[^] comment, i'd like to inform that there's a way to print directly to Zebra printer via using .net code. See: c# - .NET code to send ZPL to Zebra printers - Stack Overflow[^]

Good luck!
 
Share this answer
 
v3
Comments
MadMyche 15-Jan-19 22:08pm    
The name of the printer in the OP's original code suggests that the printer is a Zebra label printer; which generally use their own language "ZPL"; which allows directly sending plain text commands for formatting and content directly
Maciej Los 16-Jan-19 2:42am    
Tahnk you for your suggestion. I'll try to find something interesting.
MadMyche 16-Jan-19 7:05am    
I had a learn ZPL for a position a few years ago
Maciej Los 16-Jan-19 7:47am    
That explains why you were able point me out into right direction ;)
Cheers
Maciej

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900