I'm trying to write a routine that uses the Modulus 10 method to validate a number. I'm looking for some assistance with the code - has anyone done anything similar??
'This is a MOD 10 Add-Double-ADD routine.
Friend Function ComputeAddDoubleAddCheckDigit(strAcctNo As String) As String
Dim L As Integer, _
strResponse As String, _
intCk As Integer, I As Integer
L = Len(strAcctNo)
If Not (strAcctNo Like String(L, "#") Or _
strAcctNo = String(L, "0" Then
strResponse = "X"
Else
Dim aryAddDouble As Variant
'* Sum of digits in number after doubling e.g. 2*9 = 18 1+8 = 9
aryAddDouble = Array(0, 2, 4, 6, 8, 1, 3, 5, 7, 9)
For I = 15 To 1 Step -2
intCk = intCk + aryAddDouble(CInt(Mid$(strAcctNo, I, 1)))
Next
For I = 14 To 2 Step -2
intCk = intCk + CInt(Mid$(strAcctNo, I, 1))
Next
intCk = (1000 - intCk) Mod 10
strResponse = CStr(intCk)
End If
ComputeAddDoubleAddCheckDigit = strResponse
End Function
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.