This site will look much better in a browser that supports web standards, but it is accessible to any browser or Internet device.

bar code software

UPC barcode check digit calculation


Calculating UPC Check Digits

All UPC bar codes include a check digit. The UPC check digit is the 12th digit, located in the lower-right corner of the barcode itself. Calculating the UPC barcode check digit is explained below.

UPC check digit calculation

While there are 12 digits in a UPC barcode, only the first 11 digits contain user data. The last digit is a check digit based on the previous 11 numbers. Calculating the UPC check digit is "unique" mathematics. Our example barcode data is "41234554321"

Beginning on the left, add up digits in the odd positions. Multiple the result by 3. Add up all the digits in the even positions. Add the first subtotal to the second. Now what single digit number makes the total a multiple of 10? That's the check digit.

4+2+4+5+3+1=19   19x3=57   1+3+5+4+2=15   57+15=72 and 8 makes 80

If you are using UPCTools, the bundled wizard utility and sample code calculate the necessary UPC check digit for you. This page just explains what goes on under the hood.

In Visual Basic it will look something like this:

Function AzaleaUPCcheckdigit(ByVal yourInput as String) as String
' Copyright 2006 Azalea Software, Inc. All rights reserved. www.azalea.com
' The input, yourInput, is your 11-digit company prefix + product number

Dim checkDigitSubtotal As Integer ' temporary variable during the calculation

checkDigitSubtotal = 3 * (Val(Left$(yourInput, 1) + Val(Mid$(yourInput, 3, 1)) + Val(Mid$(yourInput, 5, 1)) + Val(Mid$(yourInput, 7, 1)) + Val(Mid$(yourInput, 9, 1)) + Val(Right$(yourInput, 1)))
checkDigitSubtotal = checkDigitSubtotal + Val(Mid$(yourInput, 2, 1)) + Val(Mid$(yourInput, 4, 1)) + Val(Mid$(yourInput, 6, 1)) + Val(Mid$(yourInput, 8, 1)) + Val(Mid$(yourInput, 10, 1))
AzaleaUPCcheckdigit = Right$(Str$(300 - checkDigitSubtotal), 1)

End Function