11,505,486 members (60,347 online)

# How to Generate Check Digits and verify your barcodes

, 28 Sep 2006 CPOL 61.2K 626 43
 Rate this:
Generates Check Digits and alows you to verify proper scan of a barcode

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

## Share

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

 First Prev Next
 My vote of 5 Heaven20205-Nov-10 9:16 Heaven2020 5-Nov-10 9:16
 how to generate barcode using UPC-A yutahiga3-Mar-10 13:53 yutahiga 3-Mar-10 13:53
 Re: how to generate barcode using UPC-A Polymorpher3-Mar-10 14:00 Polymorpher 3-Mar-10 14:00
 thanks for this nice work Rola /anglian/11-Jun-07 23:59 Rola /anglian/ 11-Jun-07 23:59
 Re: thanks for this nice work Polymorpher12-Jun-07 6:49 Polymorpher 12-Jun-07 6:49
 NIce Anthony Queen29-Sep-06 3:57 Anthony Queen 29-Sep-06 3:57
 Re: NIce Polymorpher29-Sep-06 6:20 Polymorpher 29-Sep-06 6:20
 Don't limit yourself Charles K. Kincaid21-Mar-06 4:41 Charles K. Kincaid 21-Mar-06 4:41
 The fomula works for code lengths other than 12 as well. The SSCC-18 and SSCC-14 both contain a "Data Check Character" which is calculated using this same fomula. See (http://www.barcodeisland.com/uccean128.phtml#AI00[^]) for the rest of the UCC 12 specification. -- ATB Charles Kincaid
 Re: Don't limit yourself Polymorpher21-Mar-06 15:04 Polymorpher 21-Mar-06 15:04
 Re: Don't limit yourself Polymorpher3-Oct-06 10:52 Polymorpher 3-Oct-06 10:52
 Last Visit: 31-Dec-99 18:00     Last Update: 3-Jun-15 8:22 Refresh 1