x.xxxx is not a valid floating point. Converting between languages/locals

前端 未结 4 1773
刺人心
刺人心 2021-01-02 08:20

I have a spanish user who is getting an invalid floating point error when doing this

var
  S : String;
  R : Real;
begin
  S := \'3.12345\';
  R         


        
4条回答
  •  遥遥无期
    2021-01-02 08:45

    If you know that the strings use . as the decimal separator, then you should do something like

    procedure TForm1.FormCreate(Sender: TObject);
    begin
      Application.UpdateFormatSettings := false;
      DecimalSeparator := '.';
    end;
    

    The line

    Application.UpdateFormatSettings := false;
    

    is very important. The default value of this property is true, and in such case, the DecimalSeparator variable may be reverted to its default value (e.g. ,) anytime, for instance when you switch user.

提交回复
热议问题