Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing to the LPT port VS2005 .NET 2.0 1

Status
Not open for further replies.

zarkon4

MIS
Dec 16, 2003
641
US
I am trying to send raw data to a label printer,
specifically a ZEBRA 105SL, using Visual Studio 2005.

I have the following code, but it is not working.

Can anyone help?

FileOpen(1, "LPT1", OpenMode.Output)
PrintLine(1, "^XA^MMC^MNN^MTT^PON^PMN^JMA^PR4,4^JUS^CI0^XZ")
PrintLine(1, "^XA")

PrintLine(1, "^LH0,0^LL" & lYLabelLen)

PrintLine(1, "^BY10,3,500^FT550," &lYBarCode& "^B3B,N,,N,N")
PrintLine(1, "^FD" & strLoc & "^FS")
PrintLine(1, "^FO580," & lYText1 & "^A0B250,250")
PrintLine(1, "^FD" & strLoc & "^FS")
PrintLine(1, "^XZ")
FileClose(1)
 
Just a thought:

You are sending "^X" etc.

Is this meant to be Ctrl-X etc?

If so then you would need to convert the letters to their alphabetic ordinal values (taking a couple of short lines as an example):

Replace :

[tt] PrintLine(1, "^XA")
PrintLine(1, "^XZ")[/tt]

With:

[tt] PrintLine(1, CHR(ASC(X) - 64)) + "A")
PrintLine(1, CHR(ASC(X) - 64)) + "Z")[/tt]

where
^A = 1
^B = 2
...
...

("A" = 65), (65 - 64 = 1)



Hope this helps.

[vampire][bat]
 
Doesn't help. The code does not even get to the PrintLine
portion. It errors on opening LPT with the following error

FileStream will not open Win32 devices such as disk partitions and tape drives. Avoid use of "\\.\" in the path.
 
By the way, although the above is for 2002/2003 it should still be valid for 2005.

[vampire][bat]
 
Thank You Chrissie1!

That was the simplest solution.
 
Hi all, i am trying to use Chrissie1 solution but i always hit with the following:

---------------------------------
An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll

Additional information: Invalid handle.
-----------------------------------

below is my code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Create object
Dim print As New Waterfurnace.ZebraPrint

'Print on the computer PC-0556 with printer name VantageT
' this is where i got the problem. any issue with my command?
print.StartWrite("\\57.33.94.74\\57.33.94.111")

'Do this because the zebra manual says so
print.Write("")
print.Write("N")

'Write Text
print.Write("A30,90,0,4,1,1,N,""" & Me.TextBox1.Text & """")

'Write bar code
print.Write("B30,20,0,1,2,5,50,N,""" & TextBox2.Text & """")

'Print a single copy
print.Write("P1")

'Clean up
print.EndWrite()

End Sub
 
57.33.94.74 is my print server address.
57.33.94.111 is my printer ip.
 
that can't be right.

What name do you give if you want to print to it directly from windows?

What is the printer share name?

it is most likely something like this.

print.StartWrite("\\57.33.94.74\printersharename")


Christiaan Baes
Belgium

"My new site" - Me
 
i just changed it to print.StartWrite("\\57.33.94.74\ZebraZ4M") but it still giving me the problem :(
sorry for the trouble... i am a novice in all these. really appreciate ur help.
 
If you are trying to print to a networked Zebra printer, you need to create it as a shared printer from a server or add a DNS entry in for it.
 
print.StartWrite("\\57.33.94.74\\ZebraZ4M")

is what I tried and it works without a problem.

Christiaan Baes
Belgium

"My new site" - Me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top