Page 1 of 1

calculate an IBAN Key and a rib for a french banking account

Posted: Mon Sep 03, 2007 11:00 am
by KIKI
Here is the method to calculate an IBAN Code for a bankin g account in all part of the word and a method to calculate the rib for a french banking account





Code: Select all

Procedure.s Caliban( compte.s, pays.s)
Protected  compte1.s,clerib.s="",clerib1.l,clerib2.l
If pays = "" ;Cas ou l'on fournit seulement le BBAN (RIB) on considére qu'il sagit d'un compte Français par défaut 
pays = "FR"
EndIf 
;On élimine les blancs et les "-"
compte = ReplaceString(compte, " " ,"")
compte = ReplaceString(compte, "-" ,"")
;Teste si le premier caractére est une lettre auxquelles cas nous sommes en face d'un IBAN
If Asc( Left(compte,1) ) >= 48 And Asc( Left(compte,1) ) <= 59
compte1.s = compte + pays + "FR00"
Else
compte1.s = Mid(compte,5,Len(compte)-4 ) + pays +"00"
EndIf 
clerib.s= ""
For i= 1 To Len(compte1)
  If Asc(Mid(compte1,i,1)) >= 65 And Asc(Mid(compte1,i,1)) <= 90 
    clerib = clerib + Str( Asc(Mid(compte1,i,1))-55)
  Else 
    clerib = clerib + Mid(compte1,i,1)
  EndIf
Next
clerib1 = ValQ( Left(clerib,19 ) ) % 97
clerib2 =98 -ValQ ( StrQ(clerib1) + Right(clerib,Len(clerib)-19 ) ) % 97
;Teste si le compte a été fourni au format BBAN ou au format IBAN 

If Asc( Left(compte,1) ) >= 48 And Asc( Left(compte,1) ) <= 59
ProcedureReturn  pays + RSet( Str(clerib2) , 2 , "0") + compte
Else 
ProcedureReturn  pays + RSet( Str(clerib2) , 2 , "0") + Mid(compte,5,Len(compte)-4)
EndIf 
EndProcedure  

Procedure.s Clef_rib(bban.s)
	;==================
	;Calculer la cle rib
	;===================
	Protected a.s,i.b=1,b.b=1,banque.s,agence.s,rib.s,compte.s,clerib2.s=""
	If Len(bban) = 23 
	banque.s= Left(bban,5)
	agence.s = Mid(bban,6,5)
	rib.s = Mid(bban,11,11)
	Else
	banque.s= Mid(bban,5,5)
	agence.s = Mid(bban,10,5)
	rib.s = Mid(bban,15,11)
	EndIf
	
	Protected HOLLERITH.s = "AJ BKSCLTDMUENVFOWGPXHQYIRZ"
	;Agence
	;===============================
	;Calcul de la cle rib
	;===============================
	For i = 1 To 11
		a = Mid(rib, i , 1 )
		If Asc(a) >= 65
					b = FindString(HOLLERITH,a ,1)
			If b % 3 <> 0
				b = Int(b / 3) + 1
			Else
				b = b / 3
			EndIf
			rib = Left(rib, i - 1) + Str(b) + Right(rib, 11 - i)
		EndIf
	Next
	compte= banque+agence+rib+"00"
	clerib1 = ValQ( Left( compte ,19 ) ) % 97
	clerib2 =  StrQ(  97- ( ValQ(  StrQ(clerib1) +Mid( compte,20,4) ) % 97) )
	clerib2 = RSet( clerib2,2,"0")
 ProcedureReturn Mid(bban,1, Len(BBan)-2)+ clerib2
EndProcedure   ;==>Clef
_rib

Posted: Wed Sep 05, 2007 4:26 am
by Rook Zimbabwe
:?: So what exactly is this useful for :?:

The only thing in Texas that uses ribs is the Barbeque place down the street...

Posted: Wed Sep 05, 2007 6:37 am
by KIKI
Rook Zimbabwe wrote::?: So what exactly is this useful for :?:

The only thing in Texas that uses ribs is the Barbeque place down the street...
When You have an account in a bank and you want to pay someone in every part of the world the way to do it is to convert you local account in a foreign account that everyone can read. This is an ISO norm and to verify that account is good you ought to verify the Key. This program allow you to calculate this key

Posted: Wed Sep 05, 2007 10:05 am
by Kaeru Gaman
this explains the key...

but a rib is on a BBQ, or with Sauerkraut, but not in a bank...?

Posted: Wed Sep 05, 2007 12:38 pm
by dell_jockey
RIB is the French language acronym for what the rest of Europe calls BIC

Posted: Sat Sep 08, 2007 2:33 am
by Rook Zimbabwe
:D BIC is a brand of Cigarrette Lighter... here anyway! I think they make disposable ballpoint pens as well... I use a Parker Fountain Pen... I don't know why anyone would use anything else!

What were we talking about???

Oh look... cheese! :D

Posted: Sat Sep 08, 2007 8:09 am
by dell_jockey
Rook Zimbabwe wrote::D BIC is a brand of Cigarrette Lighter... here anyway! I think they make disposable ballpoint pens as well...

And guess where those were made, France ! ;)

Posted: Mon Sep 10, 2007 12:47 pm
by KIKI
dell_jockey wrote:
Rook Zimbabwe wrote::D BIC is a brand of Cigarrette Lighter... here anyway! I think they make disposable ballpoint pens as well...

And guess where those were made, France ! ;)
Thanks for all which encourage programmer to shared what they do , uo are so funny !.....................................................

Posted: Mon Sep 10, 2007 2:15 pm
by DoubleDutch
I can use this code, thanks Kiki. :)