Code 11

 

Code 11 encodes only the number and a minus sign.

This code must begin with a start character and must end with a stop character. The start character is § (Chr$(167)) and the stop character is ¬ (Chr$(172)).

For convenience in typing the open bracket ( may be used as the start character, and the close bracket ) may be used as the stop character.

Code 11 provides for a single check digit when the code length is less than 12 characters, and two check digits when the code length is 12 characters or more.

In each case the check digit is calculated using a weighted modulo 11 algorithm. For the first check digit the integer value of each character is multiplied by it the rightmost digit of the character’s position (i.e. ranging from 1 to 9 and then restarting) in the code (starting from the right) and with the - sign given the value 10. The sum of these values is calculated and then divided by 11 and the remainder is used as the check digit.

‘ xx$ is the code  First check digit calculation
chn1=0:  chd$=““
n= len(xx$)
For i = n To 1 Step -1
    y$ = Mid$(xx$, i, 1)
    If y$ = "-" Then z = 10 Else z = Asc(y$) - 48'  value of character
    chn1 = chn1 + j * z
    j = j + 1
    If j > 10 Then j = 1
    Next I
t = chn1 Mod 11
If t < 10 Then
    chd$ = chd$ + Chr$(t + 48)' convert to ASCII character 0-9
    Else
    chd$ = chd$ + "-"
    End If

 

The second check digit is calculated in the same way except that the character position weightings range from 1 to 8 and then restarted. The first check digit character IS included as the rightmost character in the calculation for the second check digit.

The dFont program provided with the dLSoft Barcode fonts calculates check digits for Code 11 codes, and the source code is provided and may be adapted to the users needs - for example, for automating the calculation in a spreadsheet or database.

 

More:

Codabar