Printing barcodes using zebra printer

I need to create a windows form application in VB.Net to print barcodes on zebra printer(Z4MPlus).
I have controls where the user can select the item and enter the number of barcodes for that item.
When user clicks on Print button, barcodes should should be printed with the barcode and the item number below it. Please tell me how do I do this.
LVL 1
SGUDAPATAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AdnanKurtovicCommented:
Easiest way is to use barcode font. Those lines on barcode just represent number written below, so using this font you will actually print it just like any other text.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SGUDAPATAuthor Commented:
Do I need to purchase any software for Barcode font?
Can please give me small example what you mean by barcode font.
0
HooKooDooKuCommented:
By a barcode font, it's ment a font that outputs in a barcode.  Think of a WingDings font, but rather than fancy shapes, the font draws the lines a particular barcode uses.

There are definitly barcode fonts for sale.  Don't know if you can find any freeware bar code fonts.

Otherwise, if you know how to draw boxes on the printer, it's possible to produce you're own barcodes if you know the secifications for the font you desire.
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

SGUDAPATAuthor Commented:
I donot want to use any purchased software, I write code to generate barcodes using Vb.Net code.
0
SGUDAPATAuthor Commented:
I donot want to use any purchased software, I want to write  code to generate simple barcodes(which can be read by the scanner) using Vb.Net cod
0
HooKooDooKuCommented:
Then the first step is being able to draw boxes.  Do you know how to do that?
The next step is going to be learning the specification for the barcode you want to print.  There are several types of barcodes out there.  Just a few examples I've heard of include 2-of-5 and 3-of-9 and have different ranges of what can be printed.  As an example 3-of-9 can print 0-9, A-Z (no lower case), and the symbols *-.$/+% and <Space>.  Others can only print numbers 0-9.  Then there is the UPC Barcode specfication.  Some specifications you can find on the internet for free.  Others, it seems the only way to learn the specification is to BUY them from one of the standards committees (I know we've done that before to be able to print our own OCR font).

The only barcode specification I could help you with at all would be the 3-of-9.
0
SGUDAPATAuthor Commented:
I haven't written any barcodes application prior to this, this is my first application.
The user for whom I am writing this application doesn't have any specification about the barcodes, the only thin the user is concerns is that the barcodes cshoudl be printed using zebra printer(Z4MPlus). so please help with the 3-of-9.
0
SGUDAPATAuthor Commented:
I haven't written any barcodes application prior to this, this is my first application.
The user for whom I am writing this application doesn't have any specification about the barcodes, the only thing the user is concerns is that the barcodes should be printed using zebra printer(Z4MPlus). so please help with the 3-of-9.
0
HooKooDooKuCommented:
Here's what I can tell you about the basics 3-of-9:
Dimensions:
The optimum Height of the barcode is 0.4 inches.
The optimum Narrow Bar/Space Width is 0.01 inches.
The optimum Wide Bar/Space Width is 0.03 inches.
The bar code should start and end with a '*' symbol (so to print "123", you really print "*123*").
The code snippet below, written in VB6, draws a barcode for the given Code39 String at the given X,Y coordinates on the page.  The GoSubs Dash, Dott, Deep, and Dixx sort of defines the encoding for each character.
The GoSub Dash would draw a Wide Bar and move the distance of a Narrow Space.
The GoSub Dott would draw a Narrow Bar and move the distance of a Narrow Space.
The GoSub Deep would draw a Wide Bar and move the distance of a Wide Space.
The GoSub Dixx would draw a Narrow Bar and move the distance of a Wide Space.

The code snippet utilizes additional logic that is beyond the scope of this snippet and the implementation for which can not be provided.  However, it should suffice to say that 'Brush as clsAPIBrush' and 'R as RectDbl' implement API Brush and Rectangle objects with coordinates in decimal inches (i.e. coordinates are floating point doubles where 1.0 equals one inch).  The function and property names shown in the code should suffice to indicate what the logic is doing with these objects.

Below the example is an attempt to "Draw" a barcode with ASCII characters for the string "123".

Public Sub PrintCode39BarCode(ByVal hDC As Long, Code39 As String, X As Double, Y As Double)
Dim BarLength As Double             'Size (Height) of a Bar
Dim DotWidth As Double              'Size (Width) of a Dot      (0.01)
Dim DashWidth As Double             'Size (Width) of a Dash     (0.03)
Dim FudgeWidth As Double
 
    'Initialize Dimentions
    BarLength = 0.4
    DotWidth = 0.01
    DashWidth = 0.03
    FudgeWidth = 2# / CDbl(GetDeviceCaps(hDC, LOGPIXELSX))  'API Function Call
    
Dim BarCode As String       'String of what to Print
Dim I As Long
 
    'Insert Start/Stop Char
    BarCode = "*" & Code39 & "*"
    
PrintBarCode:
Dim Brush As clsAPIBrush    'Personal Implementation of API Brush
Dim R As RectDbl            'Rectangle UDT with floating point (double) coordinates
    
    Set Brush = New clsAPIBrush
        
    With R
        .Left = X
        .Bottom = Y
        .Right = X
        .Top = .Bottom - BarLength
    End With
    
    'Draw the Code 39
    For I = 1 To Len(BarCode)
        Select Case Mid$(BarCode, I, 1)
            'DASH = "### ", DOTT = "# ", Deep = "###   ", DIXX = "#   "
            Case "*": GoSub Dixx: GoSub Dott: GoSub Dash: GoSub Dash: GoSub Dott    'Start/Stop Char
            Case "0": GoSub Dott: GoSub Dixx: GoSub Dash: GoSub Dash: GoSub Dott
            Case "1": GoSub Dash: GoSub Dixx: GoSub Dott: GoSub Dott: GoSub Dash
            Case "2": GoSub Dott: GoSub Deep: GoSub Dott: GoSub Dott: GoSub Dash
            Case "3": GoSub Dash: GoSub Deep: GoSub Dott: GoSub Dott: GoSub Dott
            Case "4": GoSub Dott: GoSub Dixx: GoSub Dash: GoSub Dott: GoSub Dash
            Case "5": GoSub Dash: GoSub Dixx: GoSub Dash: GoSub Dott: GoSub Dott
            Case "6": GoSub Dott: GoSub Deep: GoSub Dash: GoSub Dott: GoSub Dott
            Case "7": GoSub Dott: GoSub Dixx: GoSub Dott: GoSub Dash: GoSub Dash
            Case "8": GoSub Dash: GoSub Dixx: GoSub Dott: GoSub Dash: GoSub Dott
            Case "9": GoSub Dott: GoSub Deep: GoSub Dott: GoSub Dash: GoSub Dott
            Case "A": GoSub Dash: GoSub Dott: GoSub Dixx: GoSub Dott: GoSub Dash
            Case "B": GoSub Dott: GoSub Dash: GoSub Dixx: GoSub Dott: GoSub Dash
            Case "C": GoSub Dash: GoSub Dash: GoSub Dixx: GoSub Dott: GoSub Dott
            Case "D": GoSub Dott: GoSub Dott: GoSub Deep: GoSub Dott: GoSub Dash
            Case "E": GoSub Dash: GoSub Dott: GoSub Deep: GoSub Dott: GoSub Dott
            Case "F": GoSub Dott: GoSub Dash: GoSub Deep: GoSub Dott: GoSub Dott
            Case "G": GoSub Dott: GoSub Dott: GoSub Dixx: GoSub Dash: GoSub Dash
            Case "H": GoSub Dash: GoSub Dott: GoSub Dixx: GoSub Dash: GoSub Dott
            Case "I": GoSub Dott: GoSub Dash: GoSub Dixx: GoSub Dash: GoSub Dott
            Case "J": GoSub Dott: GoSub Dott: GoSub Deep: GoSub Dash: GoSub Dott
            Case "K": GoSub Dash: GoSub Dott: GoSub Dott: GoSub Dixx: GoSub Dash
            Case "L": GoSub Dott: GoSub Dash: GoSub Dott: GoSub Dixx: GoSub Dash
            Case "M": GoSub Dash: GoSub Dash: GoSub Dott: GoSub Dixx: GoSub Dott
            Case "N": GoSub Dott: GoSub Dott: GoSub Dash: GoSub Dixx: GoSub Dash
            Case "O": GoSub Dash: GoSub Dott: GoSub Dash: GoSub Dixx: GoSub Dott
            Case "P": GoSub Dott: GoSub Dash: GoSub Dash: GoSub Dixx: GoSub Dott
            Case "Q": GoSub Dott: GoSub Dott: GoSub Dott: GoSub Deep: GoSub Dash
            Case "R": GoSub Dash: GoSub Dott: GoSub Dott: GoSub Deep: GoSub Dott
            Case "S": GoSub Dott: GoSub Dash: GoSub Dott: GoSub Deep: GoSub Dott
            Case "T": GoSub Dott: GoSub Dott: GoSub Dash: GoSub Deep: GoSub Dott
            Case "U": GoSub Deep: GoSub Dott: GoSub Dott: GoSub Dott: GoSub Dash
            Case "V": GoSub Dixx: GoSub Dash: GoSub Dott: GoSub Dott: GoSub Dash
            Case "W": GoSub Deep: GoSub Dash: GoSub Dott: GoSub Dott: GoSub Dott
            Case "X": GoSub Dixx: GoSub Dott: GoSub Dash: GoSub Dott: GoSub Dash
            Case "Y": GoSub Deep: GoSub Dott: GoSub Dash: GoSub Dott: GoSub Dott
            Case "Z": GoSub Dixx: GoSub Dash: GoSub Dash: GoSub Dott: GoSub Dott
            Case "-": GoSub Dixx: GoSub Dott: GoSub Dott: GoSub Dash: GoSub Dash
            Case ".": GoSub Deep: GoSub Dott: GoSub Dott: GoSub Dash: GoSub Dott
            Case " ": GoSub Dixx: GoSub Dash: GoSub Dott: GoSub Dash: GoSub Dott
            Case "$": GoSub Dixx: GoSub Dixx: GoSub Dixx: GoSub Dott: GoSub Dott
            Case "/": GoSub Dixx: GoSub Dixx: GoSub Dott: GoSub Dixx: GoSub Dott
            Case "+": GoSub Dixx: GoSub Dott: GoSub Dixx: GoSub Dixx: GoSub Dott
            Case "%": GoSub Dott: GoSub Dixx: GoSub Dixx: GoSub Dixx: GoSub Dott
        End Select
    Next I
 
    Set Brush = Nothing
    Exit Sub
 
Dash:
    With R
        .Right = .Left + DashWidth - FudgeWidth
        Call Brush.FillRect(hDC, R)
        .Left = .Right + DotWidth + FudgeWidth
    End With
    Return
    
Dott:
    With R
        .Right = .Left + DotWidth - FudgeWidth
        Call Brush.FillRect(hDC, R)
        .Left = .Right + DotWidth + FudgeWidth
    End With
    Return
    
Deep:
    With R
        .Right = .Left + DashWidth - FudgeWidth
        Call Brush.FillRect(hDC, R)
        .Left = .Right + DashWidth + FudgeWidth
    End With
    Return
 
Dixx:
    With R
        .Right = .Left + DotWidth - FudgeWidth
        Call Brush.FillRect(hDC, R)
        .Left = .Right + DashWidth + FudgeWidth
    End With
    Return
    
End Sub
 
'This code shoudld draw a barcode for the string "123" that looks something like this:
#      #  ###  ###  #  ###  #      #  #  ###  #  ###      #  #  ###  ###  ###      #  #  #  #      #  ###  ###  #
#      #  ###  ###  #  ###  #      #  #  ###  #  ###      #  #  ###  ###  ###      #  #  #  #      #  ###  ###  #
#      #  ###  ###  #  ###  #      #  #  ###  #  ###      #  #  ###  ###  ###      #  #  #  #      #  ###  ###  #
#      #  ###  ###  #  ###  #      #  #  ###  #  ###      #  #  ###  ###  ###      #  #  #  #      #  ###  ###  #
#      #  ###  ###  #  ###  #      #  #  ###  #  ###      #  #  ###  ###  ###      #  #  #  #      #  ###  ###  #
#      #  ###  ###  #  ###  #      #  #  ###  #  ###      #  #  ###  ###  ###      #  #  #  #      #  ###  ###  #
#      #  ###  ###  #  ###  #      #  #  ###  #  ###      #  #  ###  ###  ###      #  #  #  #      #  ###  ###  #
#      #  ###  ###  #  ###  #      #  #  ###  #  ###      #  #  ###  ###  ###      #  #  #  #      #  ###  ###  #
#      #  ###  ###  #  ###  #      #  #  ###  #  ###      #  #  ###  ###  ###      #  #  #  #      #  ###  ###  #
#      #  ###  ###  #  ###  #      #  #  ###  #  ###      #  #  ###  ###  ###      #  #  #  #      #  ###  ###  #
#      #  ###  ###  #  ###  #      #  #  ###  #  ###      #  #  ###  ###  ###      #  #  #  #      #  ###  ###  #
#      #  ###  ###  #  ###  #      #  #  ###  #  ###      #  #  ###  ###  ###      #  #  #  #      #  ###  ###  #
 
<- Here is the '*' ---><- Here is the '1'----><- Here is the '2'----><- Here is the '3'----><- Here is the '*' ->

Open in new window

0
AdnanKurtovicCommented:
Like I said, easiest way is to use barcode font. You can download FREE one here:
http://www.barcodesinc.com/free-barcode-font/

How to generate it? Easy. Let's say your product barcode number (number that is located just beneath barcode lines) is 123456789. So you will write 123456789 using any font (Arial, ...) and then change font to Code 39 Font TrueType that you download from site above. You can try this in Word. You will see barcode lines. That is it. In VB just set Text box font in Text box where you write barcode number to be Code 39 Font TrueType and voila :D

Here is another one font if you dont like previous. It is also FREE:
http://freebarcodefonts.dobsonsw.com/code128font-download.html
0
AdnanKurtovicCommented:
I have to note that HooKooDooKu barcode will be unreadable for most (maybe all) barcode scanners. It is nice idea to play with, but is impractical. This is my opinion from practice since barcode scanners are very sensitive.
0
HooKooDooKuCommented:
I have to admit that with my first implementation, I was having a problem with getting the bars to be just the right size.  The issue you have to take into account is pixel size of your printer.  You can see in the code above that there is a 'FudgeWidth' factor that had to come into play to get the barcodes to actually print to just the right size, and this was required for a LaserJet printer printing at 300 or 600dpi.  I'm not familier with a Zebra Printer, so I don't know what if any different type of fudge factor would be needed to get the barcode to print at the appropriate dimensions.  

Obviously using a barcode font, all of that has already been calculated for you.  You only have to make sure the barcode font is included in your application.  An easier task to learn that to learn to draw boxes if you haven't learned to do that accurately.

The one other plus side to writing it yourself would be the fact that you state your only trying to get this to work on a single type of printer.  If Fudge Factors are required, at least you only have one machine to test and get it working with.
0
planoczCommented:
Here is a link that has a sample example on how to print barcodes

http://www.experts-exchange.com/Microsoft/Development/Visual_Studio_Express/Q_23477644.html
0
AdnanKurtovicCommented:
Author stated "I used ZPL manual to write the ZPL code for printing the labels using the zebra printer." but question actually was how to print barcodes. In thread there was multiple working solutions, but author at the end never not stated he tried nor solutions are not working, so I request points to be diveded between me and HooKooDooKu.
0
SGUDAPATAuthor Commented:
Thanks for replying back to me! I used the ZPL code in my program to print the barcodes.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.