Click here to Skip to main content
15,867,594 members
Articles / Programming Languages / Visual Basic
Article

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 82.9K   993   44   10
Generates Check Digits and alows you to verify proper scan of a barcode

Sample Image - BarcodeCheckDigAndVerify.png

Introduction

This only does 12 digit barcodes for now. if your interested in how this works go to
www.howstuffworks.com/upc.htm 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

License

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


Written By
Software Developer (Senior) www.ruskin.com
United States United States
PC Programmer/Analyst

Comments and Discussions

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