Autor Beitrag
Sira
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18

Windows XP
D3Prof, D6Prof
BeitragVerfasst: Di 23.11.04 18:36 
meine frage ist ganz einfach.

Ich führe berechnungen durch und bekomm solch eine Zahl raus
47.151,60 aber ich möchte (zwingend notwendig) das sie so geschrieben wird 47151.60.

Wie sieht dafür der Befehl aus?
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: Di 23.11.04 19:36 
Eine Mischung aus DecimalSeparator, ThousandSeparator und Format/StrToFloatF.

Gruß,
Jörg

_________________
Die Antworten auf die 5 häufigsten Fragen:
1. Copy(), Pos(), Length() --- 2. DoubleBuffered:=True; --- 3. Application.ProcessMessages bzw. TThread --- 4. ShellExecute() --- 5. Keine Vergleiche von Real-Typen mit "="!
Sira Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18

Windows XP
D3Prof, D6Prof
BeitragVerfasst: Di 23.11.04 22:19 
irgendwie kann ich mit deiner Antwort nun nichts anfangen!!! Wollte nur erwähnen das ich vor 2 wochen noch keine ahnung von delphi hatte.

Wär dankbar wenn du/ihr mir das Schritt für Schritt erklären könntet. thx :P
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Di 23.11.04 22:31 
ausblenden Delphi-Quelltext
1:
2:
3:
ThousandSeperator := ',';
DecimalSeperator := '.';
DeineZahlAlsText := Format('%.2f', [DeineZahl]);

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Sira Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18

Windows XP
D3Prof, D6Prof
BeitragVerfasst: Fr 26.11.04 14:22 
Also irgendwie klappt das nicht, was du mir da schreibst. aber ich hab ne lösung gefunden und zwar sieht die so aus
label1.caption:= Floattostrf (a,ffGeneral, 8,2);

früher hate ich
label1.caption:= Floattostrf (a,ffnumber, 8,2); stehen.

thx
------------------------------------------------------------------
Sorry das stimmt nur zum teil. der zeitg mir jetzt zwar kein punkt mehr an aber zuviele kommzahlen....Heul


:cry: :cry: :cry: :cry: :cry: :cry: :cry:


Zuletzt bearbeitet von Sira am Fr 26.11.04 17:24, insgesamt 1-mal bearbeitet
Stübi
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 331

Win XP, Win 2000, Win ME
D5 Ent, D7 Prof, D2005 PE, C#
BeitragVerfasst: Fr 26.11.04 14:28 
Wie berechnest du?
Hast du den Rückgabewert in einem String? Wenn ja lösche einfach den punkt raus.
Und zwar kannst du mit pos die Position des Punktes herausfinden und mit del den Punkt löschen.

[edit] Sorry für meine schlechte Antwort, aber mir wurden die Beiträge von heute gar nicht angezeigt [/edit]

_________________
Neun von zehn Stimmen in meinen Kopf sagen, dass ich nicht verrückt sei. Die zehnte summt die Tetrismelodie.
Sira Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18

Windows XP
D3Prof, D6Prof
BeitragVerfasst: Sa 27.11.04 09:04 
:cry: :cry: :cry: :cry: :cry: :cry: :cry: Sorry das stimmt nur zum teil. der zeigt mir jetzt zwar kein punkt mehr an aber zuviele kommzahlen....Heul

:cry: :cry: :cry: :cry: :cry: :cry: :cry:
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Sa 27.11.04 15:36 
Hi,

um das Rätzelraten ein wenig zu verkürzen, könntest du Sira hier einfach den entsprechenden Teil aus deinem Quelltext Posten. Denn anhand dessen, kann man dir besser helfen.

Gruß
Klabautermann
ScorpionKing
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1150

Win XP

BeitragVerfasst: Sa 27.11.04 15:41 
also bei mir klappt das mit dem floattostrf();

_________________
Aus dem Urlaub zurück!
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Sa 27.11.04 16:39 
Wieso machst du es nicht wie BenBe gesagt hat?
ausblenden Delphi-Quelltext
1:
2:
3:
ThousandSeperator := ',';  
DecimalSeperator := '.';  
DeineZahlAlsText := Format('%.2f', [Deine Zahl]);
Sira Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18

Windows XP
D3Prof, D6Prof
BeitragVerfasst: So 28.11.04 08:21 
ich hab hier mal ne passage rauskopiert.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
o := (c8-c7)/Sgem ;
a := (d8-d7)/Sgem ;
Panel1.Caption := Floattostrf(o, ffnumber, 8, 7) ;
Panel2.Caption := Floattostrf(a, ffnumber, 8, 7) ;
Probe1 :=  sqr(a) + sqr(o) ;
Panel3.Caption := Floattostrf(Probe1, ffnumber, 8, 7) ;
Masfkt:= sger/sgem ;
Panel4.Caption := Floattostrf (Masfkt, ffnumber, 8,8);
if (masfkt< 1) then ppm := ((1000-(masfkt*1000))*1000);
if (masfkt< 1) then Panel10.Caption := Floattostrf (ppm, ffnumber, 4,4);
if (masfkt> 1) then ppm := (((Masfkt*1000)-1000)*1000);
if (masfkt> 1) then Panel10.Caption := Floattostrf (ppm, ffnumber, 4,4);



und so zeigt er mir die zahlen beispielsweise mit 500.221,12 an, anstatt 500221,12

und Das mit dem decimalseperator.... weis nicht wohin das soll(habs mal versucht aber ist nicht gelaufen, compilier fehler).
----------------------------------------------------------------------------
das smily sollte nicht dazu gehören ist durch den text entstanden

Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt.
------------------------------------------------------------------------ problem gelöst lösung war das format fffixed ... um dann noch das komma durch einen punkt zu ersetzten hab ich eifnach frac (zeigt nur kommazahl dann an)bentuzt