fabio2012
11-13-2012, 05:34 AM
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
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