Click here to Skip to main content
11,790,613 members (63,220 online)
Click here to Skip to main content

How to Generate Check Digits and verify your barcodes

, 28 Sep 2006 CPOL 62.4K 664 43
Rate this:
Please Sign up or sign in to vote.
Generates Check Digits and alows you to verify proper scan of a barcode

Sample Image - BarcodeCheckDigAndVerify.png


This only does 12 digit barcodes for now. if your interested in how this works go to whichi is where I got most of my information. I just thought it would be nice to have a quick function to do the math for me and figured I should share Wink | ;)

a basic summary goes something like this:

To figure out what the chekdigit is suposed to be add together all of the odd digits and multiply by 3, then add all the even digits and add to the last result. Then find the number that when added to that makes it evenly divisible by to (10-(total mod 10))

To make sure a barcode is valid just do the same math but at the end say (total mod 10)==0

Its fairly basic but seems a little backwards on a string since they are zero based arrays. You just swap evens for odds


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer (Senior)
United States United States
PC Programmer/Analyst

You may also be interested in...

Comments and Discussions

GeneralMy vote of 5 Pin
Heaven20205-Nov-10 9:16
memberHeaven20205-Nov-10 9:16 
Question<ask> how to generate barcode using UPC-A Pin
yutahiga3-Mar-10 13:53
memberyutahiga3-Mar-10 13:53 
AnswerRe: how to generate barcode using UPC-A Pin
Polymorpher3-Mar-10 14:00
memberPolymorpher3-Mar-10 14:00 
Generalthanks for this nice work Pin
Rola /anglian/11-Jun-07 23:59
memberRola /anglian/11-Jun-07 23:59 
GeneralRe: thanks for this nice work Pin
Polymorpher12-Jun-07 6:49
memberPolymorpher12-Jun-07 6:49 
GeneralNIce Pin
Anthony Queen29-Sep-06 3:57
memberAnthony Queen29-Sep-06 3:57 
GeneralRe: NIce Pin
Polymorpher29-Sep-06 6:20
memberPolymorpher29-Sep-06 6:20 
GeneralDon't limit yourself Pin
Charles K. Kincaid21-Mar-06 4:41
memberCharles K. Kincaid21-Mar-06 4:41 
GeneralRe: Don't limit yourself Pin
Polymorpher21-Mar-06 15:04
memberPolymorpher21-Mar-06 15:04 
GeneralRe: Don't limit yourself Pin
Polymorpher3-Oct-06 10:52
memberPolymorpher3-Oct-06 10:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.1509028.1 | Last Updated 28 Sep 2006
Article Copyright 2006 by Polymorpher
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid