checkers digits

fabiobarreto10

Registered User.
Local time
Today, 19:48
Joined
Dec 28, 2011
Messages
45
Friends, I am trying to create a function to generate checkers two digits of a number (eg, 2012001). This function is working, but for some numbers it returns 3 or 4 digits, I would like help from you to identify where the error is.

Any help is welcome.

Thank you.

Public Function GetVerifier(strNumero As String) As String

Dim N As Integer, P As Integer, S As Integer, D As Double

For N = 1 To 7
P = (P + Mid(strNumero, N, 1) * N) Mod 11
Next

If P < 3 Then
P = 0
End If

D = strNumero & P


For N = 1 To 8
S = (S + Mid(D, N, 1) * (N - 1)) Mod 11
Next

If S < 3 Then

S = 0
End If

GetVerifier = P & S

End Function
 
Hello, I am sorry if I am being a cave man here, but I am not sure what this function does.. any info on what is Checkers digit?
 
You should step through the code and test the results.

Or if you can't do that place a series of Mesage Boxes to display the various vales.

Either way will tell you where the problem/s are.
 
The code generates a pair of check digits for a given number string.

Code:
 2012801      06
 2012802      70
 2012803      46
 2012804      04
...

I believe that the trouble is that you are using "Mod 11" (0 - 10) instead of "Mod 10" (0-9). The variables P and S are being allowed to have a value of 10 rather than just 0 to 9.

Change it to "Mod 10" and it should work as expected.
 
Perfect nanscombe, just switched mod11 to mod10, and it worked perfectly. I appreciate the help of all of you.

thank you so very much.
 

Users who are viewing this thread

Back
Top Bottom