Jump to content
Sign in to follow this  

Check Sum

Recommended Posts


Is there a check sum #include based on the UPC check formula been written for AutoIT? The the last digit in the number is the check sum and is derived by applying a formula to the first digits 'excluding the check sum number' and subtracting that number from 10.

This code works on 9 digits

#include <Array.au3>

dim $CheckSum[9]
$CheckDigit = 123456782

;//Populate The Checksum Array
For $i = 0 to UBound( $CheckSum ) - 1
    $CheckSum[$i] = Stringmid($CheckDigit, $i, 1)
;Calculate the CheckSum
$CheckSumOdd = ($CheckSum[1] + $CheckSum[3] + $CheckSum[5] + $CheckSum[7]) * 3
$CheckSumEven = $CheckSum[2] + $CheckSum[4] + $CheckSum[6] + $CheckSum[8]
$CheckSumCal = 10 - StringRight($CheckSumOdd + $CheckSumEven,1)
Edited by anixon

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this