Click here to Skip to main content
Click here to Skip to main content

How to Generate Check Digits and verify your barcodes

, 28 Sep 2006 CPOL
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

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 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

License

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

Share

About the Author

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

Comments and Discussions

 
GeneralMy vote of 5 PinmemberHeaven20205-Nov-10 10:16 
Question<ask> how to generate barcode using UPC-A Pinmemberyutahiga3-Mar-10 14:53 
AnswerRe: how to generate barcode using UPC-A PinmemberPolymorpher3-Mar-10 15:00 
Generalthanks for this nice work PinmemberRola /anglian/12-Jun-07 0:59 
GeneralRe: thanks for this nice work PinmemberPolymorpher12-Jun-07 7:49 
GeneralNIce PinmemberAnthony Queen29-Sep-06 4:57 
GeneralRe: NIce PinmemberPolymorpher29-Sep-06 7:20 
GeneralDon't limit yourself PinmemberCharles K. Kincaid21-Mar-06 5:41 
GeneralRe: Don't limit yourself PinmemberPolymorpher21-Mar-06 16:04 
GeneralRe: Don't limit yourself PinmemberPolymorpher3-Oct-06 11: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
Web01 | 2.8.141216.1 | Last Updated 28 Sep 2006
Article Copyright 2006 by Polymorpher
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid