Click here to Skip to main content
15,443,778 members
Articles / Programming Languages / Visual Basic
Posted 1 Feb 2006


44 bookmarked

How to Generate Check Digits and verify your barcodes

Rate me:
Please Sign up or sign in to vote.
4.63/5 (13 votes)
28 Sep 2006CPOL
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 ;)

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)

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

Comments and Discussions

GeneralMy vote of 5 Pin
Global Analyser5-Nov-10 9:16
MemberGlobal Analyser5-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    Praise Praise    Rant Rant    Admin Admin   

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