Printing Barcodes from Vb6.0

Posted on 2006-04-28
Last Modified: 2016-08-25
Hi Experts!

Have designed an application in Vb6.0 and Access 2000 as backened... In the application I have an option to print barcodes... I want to generate barcodes depending on the number of qty entered by the user to print the barcode labels... Now the problem faced my me is that when the Qty entered is 1 the barcode prints 1 label properly, when Qty = 2 is two barcode labels get printed, but when qty entered is 10 only 3 barcode labels get printed... What is the reason for this??? Please help m pasting my code below which i use to generate and print barcode labels...

My code is as follows :

Private Sub cmdPrintBarcode_Click()
Dim i As Integer
Dim BQty As Integer
'Text2(2) -> GarmentCode
'Text2(8) -> UnitPrice
'Text2(9) -> Qty

If Not IsNull(Text2(2).Text) Or (Text2(2).Text) <> "" Then
    If IsNull(Text2(8).Text) Or (Text2(8).Text) = "" Then
        MsgBox "Please enter Unit Price", vbExclamation, "Unit Price"
    ElseIf IsNull(Text2(9).Text) Or (Text2(9).Text) = "" Then
        MsgBox "Please enter Qty Purchased", vbExclamation, "Qty Purchased"
        'Else generate barcode
        'BQty stores the Qty of Garments purchased...
        BQty = Text2(9).Text
        For i = 1 To BQty
            'Barcode generation and print code...
            Open "c:\abc.txt" For Output As #1
            Print #1, Chr(2) & "L"
            Print #1, "D11"
            Print #1, "H11"
            Print #1, "PC"
            Print #1, "SC"
            Print #1, "R0001"
            Print #1, "C0001"
            'Prints CompanyName
            Print #1, "191100100550013" & "ABCL"
            'Prints Amount next to CompanyName
            Print #1, "191100100550092" & "Rs." & Format(Me.Text2(8).Text, "##,##0.00")
            'Prints GarmentCode- GarmentCategory - Size
            Print #1, "191100100450012" & Me.Text2(2).Text & " - " & Me.Combo1(2).Text & " - Size " & Me.Text2(5).Text
            'Prints Description
            Print #1, "191100100350012" & Me.Text2(6).Text
            'Prints Barcode (e - only barcode is printed)
            Print #1, "1e2202100100012" & Me.Text2(2).Text  'will print barcode..
            '9 Human readable
            'E - Barcode with number is printed
            'small e - only barcode is printed
            'column position 10
            Print #1, "Q0001"
            Print #1, "E"
            Close #1
            Shell "c:\abc.bat", vbMinimizedFocus
        Next i
    End If
End If
End Sub


Any help would be appreciated...

Thank you
Question by:twinkle2003
    LVL 44

    Accepted Solution

    Hi twinkle2003,

    Can you not simply do away with the loop and set the quantity in the line : Print #1,"Q0001", make this

    Print #1,"Q" & Format(BQty,"0000")

    This looks similar to Sato or Zebra printer coding so the Qxxxx is the number of labels to print.

    Tim Cottee

    Author Comment

    Hi Tim!!

    That was a excellent solution... Thank you...


    Expert Comment

    by:Shaukat ali

    Can u pls explain me how u r using the barcode reading and, also type of barcode, need to implement in my project. thanks , in vb6 - access

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
    Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now