![]() |
Zahlenformatierung 00001 , 00002
Hallo alle zusammen.
Ich hab da mal eine Frage: Wie kann ich einen string erzeugen der folgendermassen aussieht. V00001.txt V00002.txt V00003.txt . . V01358.txt usw Kann mann irgendwie einen Zahl Formatieren das sie als Basis 00001 hat ? :gruebel: |
Re: Zahlenformatierung 00001 , 00002
siehe funktion format in der online help
|
Re: Zahlenformatierung 00001 , 00002
Hallo Bundy,
so sollte es gehen
Delphi-Quellcode:
bye
NewFileName := Format('V%0.5d.txt', [Zahl]) ;
Claus |
Re: Zahlenformatierung 00001 , 00002
moin,
praktisch ist auch die Funktion FormatFloat, die meines Erachtens einfacher (zumindest intuitiver) zu bedienen ist. |
Re: Zahlenformatierung 00001 , 00002
Danke es funzt :dancer: :hello: :dancer: :hello: :dancer:
|
Re: Zahlenformatierung 00001 , 00002
hi,
hier eine simple Methode es ohne Format zu lösen. Man könnte ja mal mit GetTickCount messen, welche Methode schneller ist.
Code:
procedure TForm1.Button1Click(Sender: TObject); const Max = 1000; const Name = 'v'; var i, j, LMax, Ls: Integer; var s, Text: string; begin LMax := Length(IntToStr(Max)); if LMax > 1 then begin for i := 1 to Max do begin s := IntToStr(i); {Die Zahl in einen Integer umwandelm} Ls := LMax - Length(s); {Die Länge der Zahl ermitteln minus der Gesamtlänge von Max} if (Ls < LMax) and (Ls > 0) then for j := 1 to Ls do s := '0' + s; {mögliche Nullen dranhängen} s := Name + s; {Namen dranhängen} ListBox1.Items.Add(s); {Die Zahlen in die Liste eintragen} end; end; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 17:51 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz