1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| Function Fncleitf(chaine$) As String
If IsNull(chaine$) Or _
Not IsNumeric(chaine$) Then Exit Function
Dim i As Integer, l As Integer
Dim CarCTL As Integer
Dim Cle As Integer, ModCar As Integer
l = Len(chaine$)
If l Mod 2 = 0 Then
chaine$ = "1" & chaine$
End If
For i = Len(chaine$) To 1 Step -1
CarCTL = CarCTL + Val(Mid(chaine$, i, 1)) * IIf(i Mod 2 = 0, 1, 3)
Next i
ModCar = CarCTL Mod 10
Cle = IIf(10 - ModCar = 0, 0, 10 - ModCar)
Fncleitf = chaine$ & CStr(Cle)
End Function |
Partager