Thema: Delphi string in integer

Einzelnen Beitrag anzeigen

marabu

Registriert seit: 6. Apr 2005
10.109 Beiträge
 
#4

Re: string in integer

  Alt 26. Mai 2006, 13:22
Ohne Worte.

Delphi-Quellcode:
function ZeroPad(n: Cardinal; places: Byte): String;
begin
  Result := Format(Format('%%.%dd', [places]), [n]);
end;
Alternativ:

Delphi-Quellcode:
function ZeroPad(s: String; size: Word): String;
begin
  if Length(s) < size
    then Result := StringOfChar('0', size - Length(s)) + s
    else Result := s;
end;
Grüße vom marabu
  Mit Zitat antworten Zitat