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 | + | == Function IsValidIBAN == |
− | + | Function IsValidIBAN() checks if an IBAN is valid. | |
<syntaxhighlight> | <syntaxhighlight> | ||
+ | function IsValidIBAN( s: string ): boolean; | ||
− | function ReplaceLetterWithNumbers ( | + | function ReplaceLetterWithNumbers( ch: char ):string; |
− | var | + | var |
− | + | i: integer; | |
− | begin | + | begin |
− | + | i := ord( upcase( ch ) ) - ord( 'A' ) + 10; | |
− | + | result := IntToStr( i ); | |
− | end; | + | end; |
− | |||
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 := | + | a_char := s1[1]; |
− | delete(s1, 1, 1); | + | delete( s1, 1, 1 ); |
− | s := s + ReplaceLetterWithNumbers ( a_char ) ; | + | s := s + ReplaceLetterWithNumbers( a_char ); |
− | a_char := | + | 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); | |
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;