![]() |
General Programming »
Algorithms & Recipes »
Algorithms
Intermediate
License: The Code Project Open License (CPOL)
How to Generate Check Digits and verify your barcodesBy PolymorpherGenerates Check Digits and alows you to verify proper scan of a barcode |
VB.NET 1.1, WinXPVS.NET2003, Dev
|
|
Advanced Search Add to IE Search |
|
|
||||||||||||||||||

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
| You must Sign In to use this message board. | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 28 Sep 2006 Editor: Chris Maunder |
Copyright 2006 by Polymorpher Everything else Copyright © CodeProject, 1999-2009 Web22 | Advertise on the Code Project |