Autor Beitrag
Henry
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 619

WinXP Prof. SP3
D6 Prof.
BeitragVerfasst: So 15.07.07 21:32 
Hallo,

ich möchte mir einen Wert (Realvariable) in einen String formatieren und dabei die Vor und Nachkommastellen festlegen.
Damit ich dazu nicht noch eine Zweite Variable (String) brauche möchte ich das Ganze mit der Funktion Format() machen.
Vor dem Komma möchte ich gen führende Nullen haben.

Folgendes habe ich nun versucht:
ausblenden Delphi-Quelltext
1:
Label17.Caption := Format('%3.2f',[Messstrecke]);					

Dabei werden zwar die Nachkommastellen auf zwei beschränkt, aber leider habe ich keine führenden Nullen vor dem Komma.

Gibt es da eine Möglichkeit mit der Funktion Format()?
Sonst muss ich es wieder mit einer zweiten Variable mit der Funktion Str() machen.

Danke schon einmal für die Hilfe


Moderiert von user profile iconKlabautermann: Topic aus Sonstiges (Delphi) verschoben am Mo 16.07.2007 um 10:16

_________________
mfg Henry
Dunkel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 682

Mac OS X Snow Leopard
Xcode 3.1
BeitragVerfasst: So 15.07.07 21:51 
Hallo!
user profile iconHenry hat folgendes geschrieben:
Gibt es da eine Möglichkeit mit der Funktion Format()?

Ich habe zumindest, als ich ähnliches vor hatte, keine Möglichkeit mit Format(); gefunden und habe mir was eigenes gebastelt.

_________________
Ich streite einsam mich mit dieser Oberflächenwelt
Gutes sei ein löblich Brot von dem ich zehre - bis zum Tod [Das Ich - Im Ich]
Henry Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 619

WinXP Prof. SP3
D6 Prof.
BeitragVerfasst: So 15.07.07 21:54 
Hm, das ist schade.
Dann muss ich wohl bei der Variante mit Str() bleiben. Ich wollte nur versuchen das Kaos mit den Variablen so klein wie möglich halten.

_________________
mfg Henry
Phantom1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 390



BeitragVerfasst: So 15.07.07 22:04 
Mit FormatFloat geht das:

ausblenden Delphi-Quelltext
1:
Label17.Caption := FormatFloat('000.00', Messstrecke);					


mfg
Henry Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 619

WinXP Prof. SP3
D6 Prof.
BeitragVerfasst: So 15.07.07 23:26 
Danke,

genau danach habe ich gesucht.

_________________
mfg Henry