Autor Beitrag
Florian.K
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 130

Win Xp Prof. & SP 2
Delphi 10 Lite
BeitragVerfasst: So 21.09.08 20:18 
Hi Community !
Hab da 2 folgende Probleme.
Ich lasse mir etwas in meiner Memobox ausgeben und würde es gerne auf 2 Stellen nach dem Komma belassen(%.2f).
Nur weiß ich nicht wie ichs in dieser Syntax einbauen kann.
Die andere Frage ist wie ich denn einen String mit einbinde ' das Ergebnis lautet '.


Memo.Box.lines.add(floattostr((Gehalt))); /// Hier soll sozusagen noch nen String mit rein ' Dein Gehalt beträgt ' und sollte 2 Stellen nach dem Komma sein.


Mfg
Florian
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: So 21.09.08 20:38 
user profile iconFlorian.K hat folgendes geschrieben:
%.2f

Das ist schon mal ein guter Anfang! :zustimm:

Du suchst wahrscheinlich Format. Mit dieser netten Funktion kannst du in eine Format-Vorlage Variablen einbauen lassen.

Dein Format-String lautet also:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
'Dein Gehalt beträgt %.2f'
// Normaler Text     ^ ^
//                   | +--------------------|
//              Variablen-Anfang     Auf 2 Stellen runden

Und die Format-Funktion rufst du wie folgt auf:

ausblenden Delphi-Quelltext
1:
FormatierterString := Format('Dein Gehalt beträgt %.2f', [Gehalt]);					

Grüße,
Yogu