错误:未声明的标识符 'DecimalSeparator' 和 'StringReplace' 的无重载版本

Errors: Undeclared identifier 'DecimalSeparator' and no overloaded version of 'StringReplace'

您好,我一直在编码,到目前为止,在 WinXP 的 Delphi 2007 中开发和编译没有问题,直到 Win7 中的 Delphi XE7。

我不确定为什么会这样。

错误指向的行

....
if(tS<>'') then
begin
  Result:=StrToFloat(StringReplace(String(tS),'.',DecimalSeparator,[]));
  Invalid:=False;
end;
....

错误:

1) [dcc32 Error] UtilNumString.pas(321): E2003 Undeclared identifier:     'DecimalSeparator'
2) [dcc32 Error] UtilNumString.pas(321): E2250 There is no overloaded version     of 'StringReplace' that can be called with these arguments   

请亲指教。 谢谢

格式设置的旧全局变量已被删除。您可以使用 FormatSettings 全局变量:

Result:=StrToFloat(StringReplace(String(tS),'.',FormatSettings.DecimalSeparator,[]));

或者,或者(理想情况下...),您可以创建本地 TFormatSettings 并使用它。

var
  fs : TFormatSettings;
begin
   fs := TFormatSettings.Create();
   Result:=StrToFloat(StringReplace(String(tS),'.',fs.DecimalSeparator,[]));
end;