Code archives/Miscellaneous/Calculate UPC-A Check Digit
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
I had to do this for work and thought I'd share. | |||||
Function CalcCheckDigit_UPCA:String(UPC:String="") Local CheckDigit:Int = 0 For i:Int = 0 Until UPC.Length CheckDigit :+ (Chr(UPC[i]).ToInt() * (1 + 2 * (i Mod 2))) Next Return (UPC+(10-(CheckDigit Mod 10))) End Function |
Comments
None.
Code Archives Forum