Calculer la clef d'un RIB
Publié : ven. 21/oct./2005 21:54
Voici quelques fonctions bancaires :
1/ vérifie la validité d'un RIB
2/ vérifie la validité d'un N° CB
ps:
les numéros cités en exemples sont totalement factices.
essayez plutot le votre, c'est toujours plus sympa
1/ vérifie la validité d'un RIB
2/ vérifie la validité d'un N° CB
Code : Tout sélectionner
Procedure.b RIB_Valider(rib.s) ; Retourne Vrai si la clé du RIB est correcte.
rib = UCase(rib)
rib = ReplaceString(rib," ","")
rib = ReplaceString(rib,".","")
rib = ReplaceString(rib,"-","")
rib = ReplaceString(rib,"A","1")
rib = ReplaceString(rib,"B","2")
rib = ReplaceString(rib,"C","3")
rib = ReplaceString(rib,"D","4")
rib = ReplaceString(rib,"E","5")
rib = ReplaceString(rib,"F","6")
rib = ReplaceString(rib,"G","7")
rib = ReplaceString(rib,"H","8")
rib = ReplaceString(rib,"I","9")
rib = ReplaceString(rib,"J","1")
rib = ReplaceString(rib,"K","2")
rib = ReplaceString(rib,"L","3")
rib = ReplaceString(rib,"M","4")
rib = ReplaceString(rib,"N","5")
rib = ReplaceString(rib,"O","6")
rib = ReplaceString(rib,"P","7")
rib = ReplaceString(rib,"Q","8")
rib = ReplaceString(rib,"R","9")
rib = ReplaceString(rib,"S","2")
rib = ReplaceString(rib,"T","3")
rib = ReplaceString(rib,"U","4")
rib = ReplaceString(rib,"V","5")
rib = ReplaceString(rib,"W","6")
rib = ReplaceString(rib,"X","7")
rib = ReplaceString(rib,"Y","8")
rib = ReplaceString(rib,"Z","9")
d1 = Val(Mid(rib,01,7))
d2 = Val(Mid(rib,08,7))
d3 = Val(Mid(rib,15,7))
d4 = Val(Mid(rib,22,2))
If d4 = (97-(62*d1+34*d2+3*d3)%97)
ProcedureReturn #True
EndIf
EndProcedure
Procedure.b CB_Valider(cb.s) ; Retourne Vrai si le n° CB est correcte.
cb = UCase(cb)
cb = ReplaceString(cb," ","")
cb = ReplaceString(cb,".","")
cb = ReplaceString(cb,"-","")
For i=1 To 16
d = Val(Mid(cb,i,1))
somme + d
If (i%2)
somme + d
If d >= 5
somme + 1
EndIf
EndIf
Next
If (somme%10)=0
ProcedureReturn #True
EndIf
EndProcedure
Debug RIB_Valider ("11111-22222-12345678901-32")
Debug RIB_Valider ("22222-33333-01234567890-09")
Debug RIB_Valider ("12345-56789-12345678901-67")
Debug CB_Valider("0000-0000-0000-0000")
les numéros cités en exemples sont totalement factices.
essayez plutot le votre, c'est toujours plus sympa
