Author: William Gerbert
Does a string looks like an integer?
Answer:
Use this function to determine, whether a given string represents an integer.
1 function IsInteger(TestThis: string): Boolean;
2 begin3 try4 StrToInt(TestThis);
5 except6 on EConvertError do7 result := False;
8 else9 result := True;
10 end;
11 end;
Note: Due to the exception, the program is slow for non-numerical strings. If you expect non-numerical strings very often, you may use a construct basing on the Val() function and evaluate the error code.