You should use the default TryStrToFloat() function from the sysutils unit. It does exactly that, without exceptions.
The function result may change if the internationalization/localization settings have changed. e.g. if you switch from platform.
Secondly, please note that in the debugger you will always 'see' the exception before it is caught in the exception handler.
Michael. On Fri, 25 Nov 2011, Kjow wrote:
Hi all, I need to know if a string is a valid floating-point number, so I tried this function: function IsStrFloatNum(s: string): Boolean; begin try // try to convert the string into a floatnumber StrToFloat(s); // if there is no error the result is true Result := True; except // if there is any error the result is false Result := False; end; end; (From: http://www.swissdelphicenter.ch/torry/showcode.php?id=304 ) Well, I get this error: Debugger Exception Notification project.exe raised exception class 'EConvertError' with message: "Cross" is an invalid float I used this function some month ago in this project and it worked without problems, but now (some month after) I re-tried to re-build and re-use this function and I get this error. Did I inadvertently change something? Thank you! Kjow -- _______________________________________________ Lazarus mailing list [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
-- _______________________________________________ Lazarus mailing list [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
