Good morning to all,
i have a strange behaviour using FNCEdit with autoseparetor set to true, precision set to 2, EditType set etString and working with floatvalue
Case:
2 fncedit component setted as above an
First one dispalyed text is 460,87
Second one dispalyed text s 3.626,54
According to their value i set some gliph as
if FncEdit1.FloatValue<FncEdit2.FloatValue then glyph1.ImageIndex:=0 // Arrow down
else
if FncEdit1.FloatValue>FncEdit2.FloatValue then glyph2.ImageIndex:=1 // ArrowUp
else
glyph2.ImageIndex:=2; // Egual
But with the value as above the FncEdit1.FloatValue<FncEdit2.FloatValue is always false and check step by step i have
FncEdit1.FloatValue = 460.87
FncEdit2.FloatValue = 3.626 // Missing decimal number
Now i'm working convert text to currency removing any '.' char
My settings:
Formatsettings.ThousandSeparator = '.'
Formatsettings.DecimalSeparator = ','
Formatsettings.CurrencyDecimals = 2
I know that work with etString and float coulb be strange (if not mistaken) but if i work with etFloat (instead etString) the showed text is always without separetor.
Thank's in advance
Regards
Daniele
Hi,
For this you could work with etMoney. This will return a correct conversion.
The etString conversion does not support the floatvalue if there is a thousand separator char included. etMoney first strips the thousand separator and then uses the TryStrToFloat conversion which will include the decimal part. Included is a sample:
uses
FMX.TMSFNCUtils;
procedure TForm1.FormCreate(Sender: TObject);
var
v: Double;
begin
Formatsettings.ThousandSeparator := '.';
Formatsettings.DecimalSeparator := ',';
Formatsettings.CurrencyDecimals := 2;
TMSFNCEdit1.AutoThousandSeparator := True;
TMSFNCEdit1.Precision := 2;
TMSFNCEdit1.EditType := etMoney;
TMSFNCEdit1.Text := '3.626,54';
v := TMSFNCEdit1.FloatValue;
TTMSFNCUtils.Log(v.ToString);
end;
Hi Pieter,
thank's for reply ..
I'll use it !!
Regards
Daniele
Hi,
For this you could work with etMoney. This will return a correct conversion.
The etString conversion does not support the floatvalue if there is a thousand separator char included. etMoney first strips the thousand separator and then uses the TryStrToFloat conversion which will include the decimal part. Included is a sample:
uses
FMX.TMSFNCUtils;
procedure TForm1.FormCreate(Sender: TObject);
var
v: Double;
begin
Formatsettings.ThousandSeparator := '.';
Formatsettings.DecimalSeparator := ',';
Formatsettings.CurrencyDecimals := 2;
TMSFNCEdit1.AutoThousandSeparator := True;
TMSFNCEdit1.Precision := 2;
TMSFNCEdit1.EditType := etMoney;
TMSFNCEdit1.Text := '3.626,54';
v := TMSFNCEdit1.FloatValue;
TTMSFNCUtils.Log(v.ToString);
end;