VB6 - Code128 A,B and C-VBForums
Results 1 to 12 of 12

Thread: VB6 - Code128 A,B and C

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,727

    VB6 - Code128 A,B and C

    I wrote this code a while ago, and I tested it with an actual bar code scanner.
    The code detects automatically what subset to use, A, B or C.

    For example, if you use only numbers, it will use Code128C, and if you mix, it will change the subset within the barcode. For example, if you use a string like "123456789abcdef", it will start with Code128C, then when it reaches the alpabet characters, it will change to Code128B in the same barcode.

    Here's a screen shot of the sample application:
    Attached Images Attached Images  
    Attached Files Attached Files
    Last edited by CVMichael; Jun 6th, 2009 at 09:26 PM.

  2. #2
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    970

    Re: VB6 - Code128 A,B and C

    Quote Originally Posted by CVMichael View Post
    I wrote this code a while ago, and I tested it with an actual bar code scanner.
    The code detects automatically what subset to use, A, B or C.

    For example, if you use only numbers, it will use Code128C, and if you mix, it will change the subset within the barcode. For example, if you use a string like "123456789abcdef", it will start with Code128C, then when it reaches the alpabet characters, it will change to Code128B in the same barcode.

    Here's a screen shot of the sample application:
    CV micheal this is great, but how do u et the images into your program, is it from the barcode scanner or from a desktop scanner?
    Programming is all about good logic. Spend more time here


    (vHost for Apache) (Generate pronounceable password) (Generate random number c#) (Filter array with another array)

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,727

    Re: VB6 - Code128 A,B and C

    The code generates the barcode images...

  4. #4
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    970

    Re: VB6 - Code128 A,B and C

    oh sorry, i misunderstood u, that correct thanks anyways
    Programming is all about good logic. Spend more time here


    (vHost for Apache) (Generate pronounceable password) (Generate random number c#) (Filter array with another array)

  5. #5
    New Member
    Join Date
    Oct 2010
    Posts
    3

    Re: VB6 - Code128 A,B and C

    Hi, great job with this!
    one problem, i'm trying to print the following barcode:
    23020505543820
    but it doesn't seem to print the start code properly, i think the first double width bar is missing?
    any help would be appreciated!
    Last edited by Hack; Oct 28th, 2010 at 06:21 AM.

  6. #6
    New Member
    Join Date
    Oct 2010
    Posts
    3

    Re: VB6 - Code128 A,B and C

    in fact in the example image all of those barcodes are missing the start characters.

    i think what happens is that the barcode prints the first 2 characters as white, and therefore it is is invisible.

    I wasn't smart enought to figure out how to properly fix it, but found a workaround:
    in function Code128_Print of clsCode128.cls
    change the line:
    Ret = Replace(Code128_Str(Str), " ", "")
    to
    Ret = "11" & Replace(Code128_Str(Str), " ", "")

    That way the characters "11" will print white, but the rest of the barcode including start characters will print properly.

  7. #7
    New Member
    Join Date
    Nov 2010
    Posts
    2

    Re: VB6 - Code128 A,B and C

    Is there a way to print UCC/EAN-128 in Visual Basic 6 ?

    I'm trying to find it, but no solutions...

  8. #8
    New Member
    Join Date
    Oct 2010
    Posts
    3

    Re: VB6 - Code128 A,B and C

    see http://www.barcodeisland.com/uccean128.phtml :

    ... a UCC/EAN-128 symbol is, in fact, a Code 128 bar code. The UCC/EAN-128 symbol has the following Code 128 structure:
    1) A Code-128 Start character (A, B, or C).
    2) A Code-128 FNC1 character (character 102).
    3) Application Identifier (from AI table corresponding to data to be encoded).
    4) Data to be encoded (format depends on AI).
    5) A Code-128 checksum character.
    So just use the code given by CV Michael (but beware of the missing start character issue)

  9. #9
    New Member
    Join Date
    Nov 2010
    Posts
    2

    Re: VB6 - Code128 A,B and C

    Quote Originally Posted by berserkk View Post
    see http://www.barcodeisland.com/uccean128.phtml :



    So just use the code given by CV Michael (but beware of the missing start character issue)
    Thanks a lot, berserkk.

    I'll take a look at this.

  10. #10
    New Member
    Join Date
    May 2011
    Posts
    1

    Re: VB6 - Code128 A,B and C

    CV micheal,

    thank you very much for the code. I adapted it to a VBA class to use in excel.

    But i must warn you that tha code has some bugs:

    Line 229 of the .cls file:
    AddEntry 76, Chr(12), "I", "76", "2 2 1 1 1 4" ' FF
    Muse be:
    AddEntry 76, Chr(12), "l", "76", "2 2 1 1 1 4" ' FF

    Line 311 of the .cls file:
    If CodeArr(ArrIndex).BSet = CurrChar And ((SCode = eCode128_CodeSetC And CodeArr(ArrIndex).CSet <> CurrChar) Or (SCode = eCode128_CodeSetC And CodeArr(ArrIndex).ASet <> CurrChar)) Then
    Must be:
    If CodeArr(ArrIndex).BSet = CurrChar And ((SCode = eCode128_CodeSetC And CodeArr(ArrIndex).CSet <> CurrChar) Or (SCode = eCode128_CodeSetA And CodeArr(ArrIndex).ASet <> CurrChar)) Then


    I've also made some considerable changes in order to use the GrandZebu free code128 font. This way you can embedd this class in a VBA and ise it on the M$ excel or word.

    The new code follows in attach.


    Thanks

    Paulo Cunha
    Attached Files Attached Files
    Last edited by si_the_geek; May 16th, 2011 at 01:15 PM. Reason: removed "advertising" link

  11. #11
    New Member
    Join Date
    Mar 2012
    Posts
    1

    Re: VB6 - Code128 A,B and C

    Paulo,

    I am trying to use the code you provided in VB 6.5 (within MS Access 2003), and I get a "Run-time error '9': Subsript out of range" error message on line 247:

    Select Case CodeType
    Case eCode128_CodeSetA
    For K = 0 To UBound(CodeArr)
    If Char = CodeArr(K).ASet Then Exit For
    Next K
    Case eCode128_CodeSetB
    For K = 0 To UBound(CodeArr)
    If Char = CodeArr(K).BSet Then Exit For
    Next K
    Case eCode128_CodeSetC
    For K = 0 To UBound(CodeArr)
    If Char = CodeArr(K).CSet Then Exit For
    Next K
    End Select

    Have you seen this before? I am using the font from grandzebu.net that your reference in the top of the code.

    Thanks!
    Jeremy

    Quote Originally Posted by Pcunha View Post
    CV micheal,

    thank you very much for the code. I adapted it to a VBA class to use in excel.

    But i must warn you that tha code has some bugs:

    Line 229 of the .cls file:
    AddEntry 76, Chr(12), "I", "76", "2 2 1 1 1 4" ' FF
    Muse be:
    AddEntry 76, Chr(12), "l", "76", "2 2 1 1 1 4" ' FF

    Line 311 of the .cls file:
    If CodeArr(ArrIndex).BSet = CurrChar And ((SCode = eCode128_CodeSetC And CodeArr(ArrIndex).CSet <> CurrChar) Or (SCode = eCode128_CodeSetC And CodeArr(ArrIndex).ASet <> CurrChar)) Then
    Must be:
    If CodeArr(ArrIndex).BSet = CurrChar And ((SCode = eCode128_CodeSetC And CodeArr(ArrIndex).CSet <> CurrChar) Or (SCode = eCode128_CodeSetA And CodeArr(ArrIndex).ASet <> CurrChar)) Then


    I've also made some considerable changes in order to use the GrandZebu free code128 font. This way you can embedd this class in a VBA and ise it on the M$ excel or word.

    The new code follows in attach.


    Thanks

    Paulo Cunha

  12. #12
    New Member
    Join Date
    May 2012
    Posts
    1

    Re: VB6 - Code128 A,B and C

    Did you instantiate the class? CodeArr isn't defined until the Class_Initialize() method is run. If you're using VBA, like me, add the .cls file as a class module then, in your form or report or whatever do something like:

    Private Sub blNumber_Exit(Cancel As Integer)
    Dim Str As String
    Dim code As cls_Code128

    Str = Me.blNumber.Value
    Set code = New cls_Code128

    Me.barcode.Value = code.Code128_Str(Str)
    End Sub

    Good luck,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.