Convert string with commas to float

前端 未结 9 2153
走了就别回头了
走了就别回头了 2021-02-19 18:58

Is there a built-in Delphi function which would convert a string such as \'3,232.00\' to float? StrToFloat raises an exception because of the comma. Or is the only way to stri

9条回答
  •  执念已碎
    2021-02-19 19:29

    Try: StrToFloat(StringReplace('3,232.00', ',', '') It should get rid of the commas before doing the conversion.

    In C# / VB.NET I use would use something like decimal.convert("3,232.00", ",", "");

    I know of no way to do the conversion without stripping out the extra characters. In fact, I have a special function in my library that strips out commas and currency symbols. So a actually call MyConverer.decimalConverter("$3,232.00");

提交回复
热议问题