Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Führende Null bei Zahlen kleiner 10 (https://www.delphipraxis.net/55679-fuehrende-null-bei-zahlen-kleiner-10-a.html)

n0b0dy 25. Okt 2005 11:03


Führende Null bei Zahlen kleiner 10
 
hey,

habe irgendwie keine ahnung wie ich bei den zahlen 0..9 jeweils noch eine führende null bekomme, sodass alle zahlen von 0..100 zweistellig sind..
hab bissle mit FloatToStrF rumprobiert aber scheint nicht so das richtige zu sein..

Kann mir jemand helfen?

dahead 25. Okt 2005 11:05

Re: Führende Null bei Zahlen kleiner 10
 
um es als string anzuzeigen habe ich mir mal folg. funktion geschrieben:

Delphi-Quellcode:
  function IntToZeroStr(const Value, Digits: Integer): String;
  var
    tmpRes: String;
  begin
    if Value < 0 then
    tmpRes := IntToStr(Value * - 1) else
    tmpRes := IntToStr(Value);
    while Length(tmpRes) < Digits do
     tmpRes := '0' + tmpRes;
    Result := tmpRes;
  end;

n0b0dy 25. Okt 2005 11:07

Re: Führende Null bei Zahlen kleiner 10
 
hm oki.
jo ne funktion schreiben, hätt ich auch machen können. nur wahr mir das zu dumm ^^ ich dachte da hätte delphi schon was parat.
aber scheinbar ja doch net.
nagut dann mach ichs per eigener funktion. danke trotzdem :)


ciao

marabu 25. Okt 2005 11:28

Re: Führende Null bei Zahlen kleiner 10
 
Hier kommt noch ein Link: klick

marabu

MarcoWarm 25. Okt 2005 11:37

Re: Führende Null bei Zahlen kleiner 10
 
warum nicht einfach?

Delphi-Quellcode:
format('%.2d',[i]);


Alle Zeitangaben in WEZ +1. Es ist jetzt 14:29 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz