Requiere la librería DFF: http://www.delphiforfun.org/programs/Library/Default.htm
Código Delphi
[-]
function ControlIBAN(const Cuenta, Pais: string): string;
var
i, j: integer;
m: int64;
l: TInteger;
t: string;
s: string;
function LetterToDigit(const C: Char): string;
const
a: char = ‘A’;
var
d: byte;
begin
result := C;
if C in [‘A’..‘Z’] then
begin
d := (byte(C) – byte(a)) + 10;
result := IntToStr(d);
end;
end;
begin
l := TInteger.Create;
try
t := Cuenta + Pais + ‘00’;
s := ‘’;
j := Length(t);
for i := 1 to j do
s := s + LetterToDigit(t[i]);
l.Assign(s);
l.Modulo(97);
l.ConvertToInt64(m);
i := 98 – m;
result := IntToStr(i);
if i < 10 then result := ‘0’ + result;
finally
l.Free;
end;
end;
function FormateaIBAN(const Cuenta, Pais: string): string;
begin
result := Pais + ControlIBAN(Cuenta, Pais) + Cuenta;
end;