![]() |
Problem mit floattostrf
Hallo
ich habe folgendes Problem:
Code:
wenn z.B. a 2 ist und b 3 ist dann steht in edti1 nicht 6 sondern 6,000.
edit1.text := floattostrf (a * b, ffnumber, 7, 3);
Wie kann ich Delphi die Anweisung geben die Nullen nicht zu schreiben? |
Re: Problem mit floattostrf
Du könntest statt ffNumber
![]() |
Re: Problem mit floattostrf
Wenn aber keine grade Zahl rauskommt sollen sie auf drei Stellen nach dem Komma angezeigt werden.
|
Re: Problem mit floattostrf
:pale: Hab' mich verschrieben.. was du suchst ist ja ffGeneral, nicht ffFixed..
|
Re: Problem mit floattostrf
Ich meinte natürlich wenn keine ganze Zahl rauskommt.
|
Re: Problem mit floattostrf
du könntest
![]()
Delphi-Quellcode:
var A,B: Extended;
const Frmt: array[Boolean] of string[5] = ('#','#.000'); // A := 3; // B := 5.3; Edit1.Text := FormatFloat( Frmt[Frac(A*B) <> 0] , A*B ); {bzw.} if Frac(A*B) <> 0 then Edit1.Text := FormatFloat('#.000',A*B) //alle vorkomma-stellen, 3 nachkomma-stellen else Edit1.Text := FormatFloat('#',A*B); //nur vorkomma-stellen |
Alle Zeitangaben in WEZ +1. Es ist jetzt 20:28 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz