Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi FormatFloat Problem (https://www.delphipraxis.net/57419-formatfloat-problem.html)

w-lan 21. Nov 2005 06:21


FormatFloat Problem
 
Hallo!
Ich habe ein riesiges Problem.
Ich schreibe in ein Stringgrid eine Real-Zahl formatiert mit Formatfloat (FormatFloat('###,##0.00',Zahl)).
Dies funktioniert ja auch super. Danach lasse ich diese Zahlen addieren. Dies funktioniert auch noch super.
Nur wenn die oben eingegebene Real Zahl größer als 1000 ist, dann kommt beim addieren ein Fehler.

Fehlermeldung: 1.000,00 ist kein gültiger Gleitkommawert.

Wie bekomme ich das Formatfloat zurück, sodass kein "." in der Zahl ist?

Code:
StringGrid1.Cells[5,zahl] := FormatFloat('###,##0.00',l);

.........

d:=0;

For p:= 1 to X do    //Gesamt
begin
     d:= d + StrToFloat(StringGrid1.Cells[5,p]);
end;
Vielen Dank im Voraus!

gruß

w-lan

Sharky 21. Nov 2005 07:38

Re: FormatFloat Problem
 
Hai w-lan,

der Fehlter kommt dadruch das StrToFloag mit dem Tausendertrennzeichen "." nicht anfangen kann.
Du kannst jetzt jetzt mal Delphi-Referenz durchsuchenStrToFloatDef ansehen oder das Trennzeichen einfach vor der Konvertierung aus dem String entfernen.
Delphi-Quellcode:
d:= d +  StrToFloat(StringReplace(StringGrid1.Cells[5,p],ThousandSeparator,'',[rfReplaceAll]));


Alle Zeitangaben in WEZ +1. Es ist jetzt 13:49 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz