Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculate UPC-E barcode check digit 1

Status
Not open for further replies.

TonyG

Programmer
Nov 6, 2000
79
US
Does anybody know how to calculate a check digit for a six digit UPC-E bar code ? I tried several algorithms from various sources and cannot come up with the right check digit.

If you use a product that has a UPC-E of "0 872730 9" (the '0' being the normal bar code type for this product, the '872730' being the bar code #, and the '9' being the check digit), I don't come up with a '9' in all of the different algorithms that i used.

The same holds true for "0 263041 8". These are actual bar code numbers from products on the shelf.

Any help would be appreciated.

Thanks,
Tony
 
I had the same problem too, with the barcode of Marlboro lights which is 0 288692 5.

What the barcode reads, is the six digits in the middle. There's no other way to get the others, I think.

 
Hello John.

Thanks for your reply.

My problem is not getting the bar code reader to read all eight digits. The bar code reader works fine.

I need to know how to calculate the check digit for a six digit UPC-E bar code number using a pencil and paper or a calculator.

Thanks,
Tony
 
The check digit for UPCE is the same as the check digit as the UPCA from which it was derived. The first thing that you need to do is expand the UPCE back to UPCA with something like
Code:
UPCA = Left(UPCE, 3) & Mid(UPCE, 7, 1) & "0000" & Mid(UPCE, 4, 3)
And then compute the UPCA check digit.
Code:
'********************************************************************
'Check_Digit -- Calculate a UPC Check Digit
'            This function accepts the first 11 characters (c11) of
'            the UPCA code and computes the standard check digit for
'            the code.
'*******************************************************************
Function Check_Digit(ByVal c11 As String) As String
    Dim n  As Integer
    Dim nS As Single
    Dim nT As Single
     
    If Len(c11) < 11 Then
        ' Return blank if there are fewer than 11 characters.
        Check_Digit = &quot;&quot;
    Else
        nS = 0
        nT = 0
        For n = 1 To 11
            If Mid$(c11, n, 1) >= &quot;0&quot; And Mid$(c11, n, 1) <= &quot;9&quot; Then
                nS = nS + Val(Mid$(c11, n, 1)) * IIf(n Mod 2 = 0, 1, 3)
            Else
                Check_Digit = &quot;&quot;
                Exit Function
            End If
        Next n
        nT = (Int(nS / 10) * 10)
        nT = nT + IIf(nT = nS, 0, 10)
        Check_Digit = Trim$(Str$(nT - nS))
    End If
End Function
 
Thanks Golom.

That helps alot.

Have a Happy Holiday.

Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top