Difference between revisions of "International Bank Account Number"

From Free Pascal wiki
Jump to navigationJump to search
(Created page with "{{International Bank Account Number}} The International Bank Account Number (IBAN) is an international standard for numbering bank accounts. It is ISO 13616 standard. The IBA...")
 
Line 4: Line 4:
 
It is ISO 13616 standard. The IBAN consists of up to 34 alphanumeric characters,  
 
It is ISO 13616 standard. The IBAN consists of up to 34 alphanumeric characters,  
 
comprising a country code, two check digits and a detailed bank account-number.
 
comprising a country code, two check digits and a detailed bank account-number.
 
  
 
The country code using ISO 3166-1 alpha-2.
 
The country code using ISO 3166-1 alpha-2.
The check digits calculated according to [[ISO 7064]] (MOD97-10)
+
The check digits are calculated according to [[ISO 7064]] (MOD97-10) using [[ISO_7064#Function StrMOD97|StrMOD97]]
 
 
== Function IsValidIban ==
 
  
Function IsValidIban checks is International Bank Account Number valid.
+
== Function IsValidIBAN ==
Function StrMOD97 you find here [[ISO_7064#Function StrMOD97]]
+
Function IsValidIBAN() checks if an IBAN is valid.
  
 
<syntaxhighlight>
 
<syntaxhighlight>
 +
function IsValidIBAN( s: string ): boolean;
  
function ReplaceLetterWithNumbers ( a_char:char):string;
+
  function ReplaceLetterWithNumbers( ch: char ):string;
var
+
  var
  i: integer;
+
    i: integer;
begin
+
  begin
  i := ord( upcase( a_char ) ) - ord( 'A' ) + 10;
+
    i := ord( upcase( ch ) ) - ord( 'A' ) + 10;
  result := IntToStr( i );
+
    result := IntToStr( i );
end;   
+
  end;   
  
function IsValidIban( s:string): boolean;
 
 
var
 
var
 
   a_char: char;
 
   a_char: char;
 
   s1: string;
 
   s1: string;
   i : integer;
+
   i: integer;
 
begin
 
begin
 
   s := DelSpace( s );
 
   s := DelSpace( s );
 
   s1 := copy( s, 1, 4);
 
   s1 := copy( s, 1, 4);
   delete(s, 1, 4);
+
   delete( s, 1, 4 );
   a_char := s1[1];
+
   a_char := s1[1];
   delete(s1, 1, 1);
+
   delete( s1, 1, 1 );
   s := s + ReplaceLetterWithNumbers ( a_char ) ;
+
   s := s + ReplaceLetterWithNumbers( a_char );
   a_char := s1[1];
+
   a_char := s1[1];
   delete(s1, 1, 1);
+
   delete( s1, 1, 1 );
   s := s + ReplaceLetterWithNumbers ( a_char ) ;
+
   s := s + ReplaceLetterWithNumbers( a_char );
 
   s := s + s1;
 
   s := s + s1;
 
   i := StrMOD97( s );
 
   i := StrMOD97( s );
   Result := i = 1;
+
   result := (i = 1);
 
end;   
 
end;   
 
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 21:44, 22 March 2017

English (en) suomi (fi) français (fr)

The International Bank Account Number (IBAN) is an international standard for numbering bank accounts. It is ISO 13616 standard. The IBAN consists of up to 34 alphanumeric characters, comprising a country code, two check digits and a detailed bank account-number.

The country code using ISO 3166-1 alpha-2. The check digits are calculated according to ISO 7064 (MOD97-10) using StrMOD97

Function IsValidIBAN

Function IsValidIBAN() checks if an IBAN is valid.

function IsValidIBAN( s: string ): boolean;

  function ReplaceLetterWithNumbers( ch: char ):string;
  var
    i: integer;
  begin
    i := ord( upcase( ch ) ) - ord( 'A' ) + 10;
    result := IntToStr( i );
  end;   

var
  a_char: char;
  s1: string;
  i: integer;
begin
  s := DelSpace( s );
  s1 := copy( s, 1, 4);
  delete( s, 1, 4 );
  a_char := s1[1];
  delete( s1, 1, 1 );
  s := s + ReplaceLetterWithNumbers( a_char );
  a_char := s1[1];
  delete( s1, 1, 1 );
  s := s + ReplaceLetterWithNumbers( a_char );
  s := s + s1;
  i := StrMOD97( s );
  result := (i = 1);
end;