Ver Mensaje Individual
  #8  
Antiguo 25-07-2020
Avatar de Casimiro Notevi
Casimiro Notevi Casimiro Notevi is offline
Moderador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.040
Reputación: 10
Casimiro Notevi Tiene un aura espectacularCasimiro Notevi Tiene un aura espectacular
Tu código con la etiqueta DELPHI:

Código Delphi [-]
Function Modulo97(const s: string): integer;
var
  v, l : integer;
  alpha : string;
  number : longint;
begin
  v := 1;
  l := 9;
  Result := 0;
  alpha := '';

  while (v <= Length(s)) do
  begin
     if (l > Length(s)) then
        l := Length(s);
     alpha := alpha + Copy(s, v, l);
     number := StrToInt(alpha);
     Result := number mod 97;
     v := v + l;
     alpha := IntToStr(Result);
     l := 9 - Length(alpha);
  end;
end;

Function ControlIBAN(const cuenta, Pais: string): string;
var
  i, j: integer;
  m: int64;
  l: Integer;
  t: string;
  s: string;

  function LetterToDigit(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
  try
    t := Cuenta + Pais + '00';
    s := '';
    j := Length(t);
    for i := 1 to j do
      s := s + LetterToDigit(t[i]);
    l:= Modulo97(s);
    m:= int64(l);
    i := 98 - m;
    result := IntToStr(i);
    if i < 10 then result := '0' + result;
  except
    result :='';
  end;
end;

Function FormateaIBAN(const cuenta, Pais: string): string;
begin
  result := Pais + ControlIBAN(Cuenta, Pais) + Cuenta;
end;
Responder Con Cita