<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Printing Barcode in VB 6' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Printing Barcode in VB 6' posted on the 'Visual Basic' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2012 Programmers Heaven</copyright>
    <pubDate>Wed, 23 May 2012 06:55:57 -0700</pubDate>
    <lastBuildDate>Wed, 23 May 2012 06:55:57 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Printing Barcode in VB 6</title>
      <link>http://www.programmersheaven.com/mb/VBasic/383884/383884/printing-barcode-in-vb-6/</link>
      <description>Hello all,&lt;br /&gt;
&lt;br /&gt;
I need to write VB 6 code for Zebra TLP 2844 barcode printer. I have the printer commands with me but don't know how to send them to the printer. I tried MS Comm control but nothing is printed. I also tried Printer.Print but it printed the text only. I could not find any DLL or anything like that for this printer. I got only the Programming Guide which lists the commands. Below is the code I used. (I got the MS Comm settings code from the net). The commands are working when I tried it with the printer's command window.&lt;br /&gt;
&lt;br /&gt;
Public Sub PrintBarcode()&lt;br /&gt;
On Error GoTo eHandler&lt;br /&gt;
    Dim s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11 As String&lt;br /&gt;
    s0= &amp;amp; vbLf &amp;amp; "N" &amp;amp; vbLf&lt;br /&gt;
    s1 = "Q25,3" &amp;amp; vbLf 'Set label size&lt;br /&gt;
    s2 = "q38" &amp;amp; vbLf 'Label width setting&lt;br /&gt;
    s3 = "D10" &amp;amp; vbLf 'Set printing darkness&lt;br /&gt;
    s4 = "S4" &amp;amp; vbLf 'Set printing speed&lt;br /&gt;
    s5 = "R0" &amp;amp; vbLf 'Set left margin&lt;br /&gt;
    s6 = "B14,39,0,0,2,5,69,N," &amp;amp; Trim(txtItemCode.Text &amp;amp; "") &amp;amp; vbLf 'barcode&lt;br /&gt;
   &lt;br /&gt;
    'Text&lt;br /&gt;
    s7 = "A29,0,0,1,1,2,N," &amp;amp; txtCompName.Text &amp;amp; vbLf&lt;br /&gt;
    s8 = "A20,137,0,1,1,1,N," &amp;amp; txtItemName.Text &amp;amp; vbLf&lt;br /&gt;
    s9 = "A97,157,0,1,1,1,N," &amp;amp; "Dhs: " &amp;amp; txtPrice.Text &amp;amp; vbLf&lt;br /&gt;
    s10 = "P" &amp;amp; Val(txtQty.Text &amp;amp; "") &amp;amp; ",1" &amp;amp; vbLf 'Set how many labels to print, Number of copies of the same label.&lt;br /&gt;
   &lt;br /&gt;
    'Create a single string for the label output.&lt;br /&gt;
    s11 = s1 &amp;amp; s2 &amp;amp; s3 &amp;amp; s4 &amp;amp; s5 &amp;amp; s6 &amp;amp; s7 &amp;amp; s8 &amp;amp; s9 &amp;amp; s10&lt;br /&gt;
    With MSComm1&lt;br /&gt;
        .CommPort = 1&lt;br /&gt;
        'set the badurate,parity,databits,stopbits for the connection&lt;br /&gt;
        .Settings = "9600,n,8,1"&lt;br /&gt;
        'set the DRT and RTS flags&lt;br /&gt;
        .DTREnable = True&lt;br /&gt;
        .RTSEnable = True&lt;br /&gt;
        'enable the oncomm event for every reveived character&lt;br /&gt;
        .RThreshold = 1&lt;br /&gt;
        'disable the oncomm event for send characters&lt;br /&gt;
        .SThreshold = 1&lt;br /&gt;
        'open the serial port&lt;br /&gt;
        .PortOpen = True&lt;br /&gt;
        'Send the label data to the com port.&lt;br /&gt;
'        .Settings = "115200,N,8,1" 'Default&lt;br /&gt;
        .Output = s11&lt;br /&gt;
        .PortOpen = False&lt;br /&gt;
&lt;br /&gt;
    End With&lt;br /&gt;
Exit Sub&lt;br /&gt;
eHandler:&lt;br /&gt;
    MsgBox Err.Description, vbOKOnly + vbCritical, "Error"&lt;br /&gt;
End Sub&lt;br /&gt;
&lt;br /&gt;
I also tried:&lt;br /&gt;
&lt;br /&gt;
Public Sub PrintBarcode1()&lt;br /&gt;
On Error GoTo eHandler&lt;br /&gt;
  Open "lpt1" For Output As #1&lt;br /&gt;
&lt;br /&gt;
    Print #1, vbLf &amp;amp; "N" &amp;amp; vbLf&lt;br /&gt;
    Print #1, "Q25,3" &amp;amp; vbLf&lt;br /&gt;
    Print #1, "q38" &amp;amp; vbLf&lt;br /&gt;
    Print #1, "D10" &amp;amp; vbLf&lt;br /&gt;
    Print #1, "S4" &amp;amp; vbLf&lt;br /&gt;
    Print #1, "R0" &amp;amp; vbLf&lt;br /&gt;
    Print #1, "D10" &amp;amp; vbLf&lt;br /&gt;
    Print #1, "B14,39,0,0,2,5,69,N," &amp;amp; Trim(txtItemCode.Text) &amp;amp; vbLf&lt;br /&gt;
    Print #1, "A20,137,0,1,1,1,N," &amp;amp; txtItemName.Text &amp;amp; vbLf&lt;br /&gt;
    Print #1, "A97,157,0,1,1,1,N," &amp;amp; "Dhs: " &amp;amp; txtPrice.Text &amp;amp; vbLf&lt;br /&gt;
    Print #1, "A29,0,0,1,1,2,N," &amp;amp; txtCompName.Text &amp;amp; vbLf&lt;br /&gt;
    Print #1, "P" &amp;amp; Val(txtQty.Text &amp;amp; "") &amp;amp; ",1" &amp;amp; vbLf&lt;br /&gt;
&lt;br /&gt;
  Close #1&lt;br /&gt;
Exit Sub&lt;br /&gt;
eHandler:&lt;br /&gt;
    MsgBox Err.Description, vbOKOnly + vbCritical, "Error"&lt;br /&gt;
End Sub&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Both are not working. When I used the second method, the paper is getting inside the printer, but nothing got printed. Please help me to solve this problem. If you can give me the working code, I will be grateful.&lt;br /&gt;
&lt;br /&gt;
Thanks in advance&lt;br /&gt;
Sheenit Mathew.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/VBasic/383884/383884/printing-barcode-in-vb-6/</guid>
      <pubDate>Mon, 05 Jan 2009 03:06:32 -0700</pubDate>
      <category>Visual Basic</category>
    </item>
    <item>
      <title>Re: Printing Barcode in VB 6</title>
      <link>http://www.programmersheaven.com/mb/VBasic/383884/385681/re-printing-barcode-in-vb-6/#385681</link>
      <description>Try chaning the "lpt1" to the printer name in your second code, it should work. If the escape code are right.&lt;br /&gt;
&lt;br /&gt;
Partha Roy&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/VBasic/383884/385681/re-printing-barcode-in-vb-6/#385681</guid>
      <pubDate>Fri, 13 Feb 2009 05:58:49 -0700</pubDate>
      <category>Visual Basic</category>
    </item>
  </channel>
</rss>
