Autor Beitrag
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Di 16.05.06 20:57 
Hallo!

Ich habe einige Strings die ich formatieren lasse.
Das Problem ist, dass manche Strings so aufgebaut sind: 'Blah blub (%2f%)'. Jetzt sollte in der Klammer z.B. 3% stehen.
Geht aber nicht, wegen dem 2.% und weil dahinter noch etwas steht :(

StringReplace oder %s zu % zu formatieren fand ich ein bisschen übertrieben. Gibts da noch andere wege?


greetz

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.
wlfmario
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 114

Windos XP SP2
D7 Enterprise & D2005 PE
BeitragVerfasst: Di 16.05.06 22:02 
Ich weis nicht ob ich das richtig versanden habe, aber versuch es mal so !
ausblenden Delphi-Quelltext
1:
Label1.Caption := Format("%8.2f",[12345678.123]) + '%';					


Alles ungetestet.
Born-to-Frag Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Di 16.05.06 23:07 
user profile iconwlfmario hat folgendes geschrieben:
Ich weis nicht ob ich das richtig versanden habe, aber versuch es mal so !
ausblenden Delphi-Quelltext
1:
Label1.Caption := Format("%8.2f",[12345678.123]) + '%';					


Alles ungetestet.


Das Problem ist aber, das ich kein % anhängen will, sondern der String noch ein % beinhaltet ;)

Der String ist im Roh-Format (%2f%) und es soll z.B. 11% draus werden. Das Problem ist eben, dass er mir ne exception liefert, weil '%)' logischerweise ein fehlerhafter Wert zum formatieren ist :(

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Di 16.05.06 23:17 
Hallo,

soll '%' innerhalb eines Format-Strings eingebaut werden, musst Du es Doppeln(oder wie nennt man das noch gerade?):
ausblenden Delphi-Quelltext
1:
Format('%8.2f%%',[11.5]);					

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
Born-to-Frag Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Di 16.05.06 23:28 
Danke! Das ist was ich gesucht habe! :beer:


greetz

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.