- Tutarlılık kontrolü için fonksiyondur. Projelerinizde hesap numarası kaydı yapılırken, en azından doğru girilip girilmediğini kontrol edebilirsiniz.
- Offline bir kontroldür. Aritmetiksel sonuç TRUE veya FALSE döner.
- Aralarda boşluklar olabilir, fonksiyon içerisinden bu boşluklar değerlendirmeye alınmayacak şekilde elenirler.
Referans için bkz. WiKi
KullanımıWikipedia, the free encyclopedia yazdı:Algorithms
Validating the IBAN
An IBAN is validated by converting it into an integer and performing a basic mod-97 operation (as described in ISO 7064) on it. If the IBAN is valid, the remainder equals 1.[Note 1] The algorithm of IBAN validation is as follows:[8]
Check that the total IBAN length is correct as per the country. If not, the IBAN is invalid
Move the four initial characters to the end of the string
Replace each letter in the string with two digits, thereby expanding the string, where A = 10, B = 11, ..., Z = 35
Interpret the string as a decimal integer and compute the remainder of that number on division by 97
If the remainder is 1, the check digit test is passed and the IBAN might be valid.
Example (fictitious United Kingdom bank, sort code 12-34-56, account number 98765432):
• IBAN: GB82 WEST 1234 5698 7654 32
• Rearrange: W E S T12345698765432 G B82
• Convert to integer: 3214282912345698765432161182
• Compute remainder: 3214282912345698765432161182 mod 97 = 1
Kod: Tümünü seç
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
if CheckIBAN( 'GB29 NWBK 6016 1331 9268 19' )
then MessageDlg('IBAN OK', mtInformation, [mbOk], 0 )
else MessageDlg('IBAN Hatalıdır...', mtError, [mbOk], 0 );
end;
Kod: Tümünü seç
// IBAN = International Bank Account Number
function CheckIBAN(iban: string): Boolean;
var
iSayac,
jSayac,
Sonuc : Integer;
strIcerik : string;
iSayi : Longint;
cHarf : Char;
begin
Sonuc := 0;
// küçük harfler varsa büyük harfe çevir...
iban := UpperCase( StringReplace(iban, ' ', '', [rfReplaceAll]) );
// ilk 4 karakteri en sona taşı...
iban := iban + Copy(iban, 1, 4);
System.Delete(iban, 1, 4);
// alfanümerik karakterleri, kendi ASCII değerlerinden
// 55 sayısını çıkartarak hallerinin sayısal haliyle değiştir.
for cHarf := 'A' to 'Z'
do iban := StringReplace(iban, cHarf, IntToStr(Ord(cHarf) - 55), [rfReplaceAll]);
iSayac := 1;
jSayac := 9;
strIcerik := '';
try
while iSayac <= Length(iban) do
begin
if jSayac > Length(iban) then
jSayac := Length(iban);
strIcerik := strIcerik + Copy(iban, iSayac, jSayac);
iSayi := StrToInt(strIcerik);
Sonuc := iSayi mod 97;
iSayac := iSayac + jSayac;
strIcerik := IntToStr(Sonuc);
jSayac := 9 - Length(strIcerik);
end;
except
Sonuc := 0;
end;
Result := Sonuc = 1;
end;