Hi,
Does anyone have a working function available to use within MS ACCESS in VBA which implements the Luhn Mod 16 Algorithm to generate a check digit for an input code number such as the following example: "0B012722900021AC35B2"
LOGIC
1) Map from HEX into Decimal equivalent 0 B 0 1 2 7 2 2 9 0 0 0 2 1 A C 3 5 B 2 - becomes 0 11 0 1 2 7 2 2 9 0 0 0 2 1 10 12 3 5 11 2
2) Start with the last character in the string and move left doubling every other number -
Becomes 0 22 0 2 2 14 2 4 9 0 0 0 2 2 10 24 3 10 11 4
3) Convert the "double" to a Base 16 (Hexadecimal) format IF the conversion results in numeric output, retain the value.
Becomes: 0 16 0 2 2 E 2 4 9 0 0 0 2 2 10 18 3 A 11 4
4) Reduce by splitting down any resultant values over a single digit in length.
Becomes 0 (1+6) 0 2 2 E 2 4 9 0 0 0 2 2 10 (1+8) 3 A 11 4
5) Sum all digits. Apply the last numeric value returned from the previous sequence of calculations
Becomes 0 7 0 2 2 7 2 4 9 0 0 0 2 2 10 9 3 5 11 4
6) The sum of al l digits is 79 (0+7+0+2+2+7+2+4+9+0+0+0+2+2+10+9+3+5+11+4)
7) Calculate the value needed to obtain the next multiple of 16, in this case the next multiple 16 is 80 therefore the value is 1
8) The associated check character is 1