What is the correct way to check if a value is a date/number in Delphi
delphi
Solution
For integers, you could use TryStrToInt to check and convert without throwing exceptions:
function TryStrToInt(const s: string; out i : integer): boolean;
I'm not absolutely sure there is a full equivalent for floats, though, so you might need to use StrToFloat() and accept the possibility of a TFormatException.
Problem
What is the correct way to check if a value is a date/number in Delphi? I know other languages have functions like isDate and isNaN, but what is the Delphi equivalent? at the minute I have this ``` function isNumeric(s1:string):boolean; begin // will throw exception if its not a number // there must be a better way to do this!! try StrTofloat(s1); result := TRUE ; except result := FALSE; end; end; ``` But throwing exceptions cant be good, and it makes debugging hard as I keep seeing the exception dialogue every time the code is called.