-
2 Attachment(s)
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:
-
Re: VB6 - Code128 A,B and C
Quote:
Originally Posted by
CVMichael
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?
-
Re: VB6 - Code128 A,B and C
The code generates the barcode images...
-
Re: VB6 - Code128 A,B and C
oh sorry, i misunderstood u, that correct thanks anyways
-
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!
-
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.
-
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...
-
Re: VB6 - Code128 A,B and C
see http://www.barcodeisland.com/uccean128.phtml :
Quote:
... 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)
-
Re: VB6 - Code128 A,B and C
Quote:
Originally Posted by
berserkk
Thanks a lot, berserkk.
I'll take a look at this.
-
1 Attachment(s)
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
-
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
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
-
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,
-
Re: VB6 - Code128 A,B and C
Hello, my first post in this forum!
As I am beginner that are in my first few months of VBA coding, I need some help! I have database that I would like to print code 128-c barcode on access report. I did make this one to work http://www.accessforums.net/showthread.php?t=33878 (but that one only gives code 128-b).
As my database will be working in highly secured enviorment, I have no possibility to use an font for that. Please help out with some " step by step" explanation!
Magnus
-
Re: VB6 - Code128 A,B and C
I am not sure what step by step information you need... Do you have any specific questions?
-
Re: VB6 - Code128 A,B and C
Quote:
Originally Posted by
berserkk
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.
This fix worked for me. I have a Wasp WCS3950 handheld scanner, but it failed to read any of the original barcodes. With the fix (prefixing with "11") it recognised the following:
Testing Code 128
123456789012345678901234567890
ABCDEFGHIJ
68760980981234455
11098432135468798
but not the others. It's only the first two I would actually use (size etc) anyway. So now all I've got to do is figure out how to get the barcodes onto an A4 sheet of sticky labels.
-
Re: VB6 - Code128 A,B and C
Your scanner is probably scanning EAN-128 instead.
"EAN-128 – The UCC/EAN 128 barcode is a special form of Code 128. EAN-128 is based on Code 128 but it has a double start character. It is also called UCC128."
https://github.com/wqweto/ClipBar/bl...c/cBarCode.cls
This is a class which can produce EAN-128 (and EAN-8, EAN-13, UPC-A and UPC-E w/ all supported suffixes).
cheers,
</wqw>
-
Re: VB6 - Code128 A,B and C
Message to CVMichael (and maybe moderators): I've written a VB6 app to generate a page of 1 to 70 Code128 barcodes on an A4 sheet (5 columns x 13 rows), using your class clsCode128.cls. Have you any objection to my uploading this app to this thread in due course (it will take a few days to finalise)? Thanks.
-
Re: VB6 - Code128 A,B and C
Quote:
Originally Posted by
wqweto
Your scanner is probably scanning EAN-128 instead.
</wqw>
I downloaded a barcode verifier app for Android and the barcode was identified as Code128. The verifier also identified EAN and UPC codes from objects around the house.
-
Re: VB6 - Code128 A,B and C
EAN-128 *is* Code128 in diguise. It just has first two digits fixed/reserved and these do not get printed underneath it.
EAN (or more precisely EAN-13) is another barcode encoding altogether.
UPC-A *is* EAN-13 in diguise with first digit fixed to 0 and this digit is not printed under UPC codes. (Also note that there are no EAN-13 codes that start with 0 as these are reserved to UPC-A.)
So EAN-13 and UPC-A share the same encoding the same way EAN-128 and Code128 share the same encoding -- one is exactly like the other but with some fixed prefix/digits.
Both EAN-13 and EAN-128 encodings are complex and cannot be emulated with simple barcode fonts like most of the other (so called industial) barcode encodings in which each digit/letter is encoded w/ exactly the same bars+spaces always.
cheers,
</wqw>
-
Re: VB6 - Code128 A,B and C
Quote:
Originally Posted by
Pcunha
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
I'm trying to use that class in VB6 but I have some problems. I'm using a Code128 TTF in a label, if I encode for example M013497 it works fine and I can read the code from screen, but if I encode 2326630048 the code apparently is right but can't be readed.
Anybody has any class/module to generate Code128 string and use it with a standard Code128 TTF?
-
Re: VB6 - Code128 A,B and C
I got side-tracked by other projects and haven't touched my VB6 barcode generator for almost exactly a year. Now I've resurrected the project and found a little problem. By the way, I'm using CV Michael's original .cls with berserkks' fix [Ret = "11" & Replace(Code128_Str(Str), " ", "")].
The little problem is the .cls won't generate a barcode containing lower case l, e.g./ Bluetooth 01 is scanned as Buetooth 01, or lovely lulu 01 is scanned as ovey uu 01
I haven't checked all alpha characters yet. Anyone got ideas as to what's wrong?