# Mod 10 Overflow Follow

I'm having an issue with trying to get a correct mod 10 checkdigit from Bartender out of the UccMod10, UnisonMod10, UPSMod10, MSIMod10 & LuhnMod10, so I'm attempting to just mod my number 48101070870100065080 by 10 and I'm getting an overflow error.

Here is my coding:

dim nInputValue

nInputValue = Format.NamedSubStrings("MerchID").Value

dim num2,num3,num4

num2 = Mid(nInputValue, 1, 1)

num3 = Mid(nInputValue, 2, 1)

num4 = Mid(nInputValue, 3, 1)

Value = (Right(Asc(num2),1) & Right(Asc(num3),1) & Right(Asc(num4),1) & 99 & Format.NamedSubStrings("ConID").Value & Format.NamedSubStrings("Article").Value & Format.NamedSubStrings("Product").Value & Format.NamedSubStrings("Service").Value & Format.NamedSubStrings("PostagePaid").Value)

So to explain what I've done. I've taken a three digit letter (JDQ) and made Asc characters out of them and then taken just the right digit, used all the other fields as just numbering, giving me the number as per above. All preconfigured Mod10 algorithms are coming out incorrect. For 48101070870100065080 is giving a check digit of 5 and it should be a 0. When attempting to change to just 48101070870100065080 Mod 10, I'm getting an overflow error.

Any ideas or thoughts on this?

cheers for the help.

##### 2 comments

###### Michael Toupin (mtoupin

I want to add something to this. The built in VB Script "Mod" operator is a mathematical function that has nothing directly to do with check digits. It is the remainder if you divide by a number. So "7 mod 3" means "what is left over if I divide 7 by 3". 7 divided by 3, using only whole numbers, is 2, with a remainder of 1. (or using fractions, 2 1/3, and note the remainder is the numerator of the fractional part.) See "modulo operation" in Wikipedia to understand this better.

So your code fails for the reason Mike stated - the number is bigger than VB Script can handle as a numeric value.

Now, most check digits are calculated by taking a sum of the digits, or sometimes a weighted sum of the digits, and you might get a sum like "245" out of it, which you then take "Mod 10" and it gives you 5. So the VB Script "Mod" operator may wind up being used in a custom check digit calculation, but you can't simply apply "Mod 10" to a string.

To solve this problem you would need to find a spec on how the check digit is calculated for this particular requirement. To get an idea how it works, search for "Luhn algorithm" on wikipedia. This is not the algorithm you need (as you already figured out) however it gives you an idea of the type of technical info you need to find in order to implement this check digit. If you get stuck someone can help but not without the specification (or at least the official name) of the check digit you need.

Please sign in to leave a comment.