B4A Library dgBarcode - an all-B4A barcodes library

DonManfred

Expert
Licensed User
Longtime User
Reactions: udg

BjoernB

Member
Licensed User
this page says UPC-A codes are 12 characters long, but i still get the X instead of a barcode

B4X:
Dim bc As cls_barcode
bc.Initialize
    
ivBar.Width = bc.CodeWidth(bc.Symbologies.UPCA)
ivBar.Height = bc.CodeHeight(bc.Symbologies.UPCA)
bc.DrawBarCode(bc.Symbologies.UPCA,"123456654321",ivBar)

worked with 13 characters in EAN13, but the number i wanna display is just 12 long
 

udg

Expert
Licensed User
Longtime User
That was because 123456654321 seems to be not a valid UPCA code. Try with 614141012343
If you want to check for validity you can use
B4X:
Log(bc.IsCodeValid(bc.Symbologies.UPCA,"614141012343"))    'valid
Log(bc.IsCodeValid(bc.Symbologies.UPCA,"123456654321"))    'not valid
 

BjoernB

Member
Licensed User

i see, UPCA won't work for me, because i need 12 actual characters, not 11 + check digit
thanks

so i guess i have to use EAN13 and add the check digit myself ?
am i right?

EDIT: just found the "ComputeCheckDigit" Sub.
sorry, i'm not that used to Barcodes and didn't actually know i need a check Digit.
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…