【发布时间】:2014-09-13 22:10:03
【问题描述】:
我在这里做错了什么?我只是想将格式化字符串转换为双精度字符串,并使用作为参数传递给 StrToFloat 的 TFormatSettings。我得到以下异常:
'3,332.1' is not a valid floating point value.
千位分隔符和小数分隔符是 TFormatSettings 中的预期值(',' 和 '.')。
procedure TForm2.Button1Click(Sender: TObject);
var
FS: TFormatSettings;
S: String;
V: double;
begin
FS:= TFormatSettings.Create;
codesite.Send('ThousandSeparator', FS.ThousandSeparator); //correct ','
codesite.Send('DecimalSeparator', FS.DecimalSeparator); //correct '.'
S := '3,332.1';
try
V := StrToFloat(S, FS);
except on E: Exception do
ShowMessage(e.Message);
end;
CodeSite.Send('S', S);
CodeSite.Send('V', V);
end;
【问题讨论】:
标签: delphi delphi-xe5