Hello, I'm trying to convert 'curr > str' and 'str to curr' respectively, but I've got a problem with StrToCurrDef(). See my test below:
var s: string; c: Currency; begin c := 150.49; s := CurrToStrF(c, ffCurrency, 2); ShowMessage('OK: ' + s); // shows R$ 150,49 c := StrToCurrDef('R$ 150,49', 0); s := CurrToStrF(c, ffCurrency, 2); ShowMessage('Fail: ' + s); // shows R$ 0,00, I expected R$ 150,49 end; I tried it too: DefaultFormatSettings.CurrencyString := 'R$'; DefaultFormatSettings.DecimalSeparator := ','; DefaultFormatSettings.ThousandSeparator := '.'; c := StrToCurrDef('R$ 150,49', 0, DefaultFormatSettings); But the same problem happened, 'c' = 0. What is the best way to solve it? I have a way out, it would be this code below, but I wonder if there is something in the FCL, not to need to create this 'SomeFuncToRemoveAlphaChars' function: v := SomeFuncToRemoveAlphaChars('R$ 150,49'); // only 150,49 c := StrToCurrDef(v, 0, DefaultFormatSettings); s := CurrToStrF(c, ffCurrency, 2); // now it shows R$ 150,49 Thank you! -- Silvio Clécio My public projects - github.com/silvioprog
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal