RAD Studio VCL Reference
SysUtils.TryStrToInt Function

Converts a string that represents an integer (decimal or hex notation) to a number with Boolean success code.

function TryStrToInt(const S: string; out Value: Integer): Boolean; overload;
Boolean TryStrToInt(const AnsiString S, int Value);

TryStrToInt converts the string S, which represents an integer-type number in either decimal or hexadecimal notation, into a number, which is assigned to Value. If S does not represent a valid number, TryStrToInt returns false; otherwise TryStrToInt returns true. 

To accept decimal but not hexadecimal values in the input string, you may use code like this:

function TryDecimalStrToInt( const S: string; out Value: Integer): Boolean;
   result := ( pos( '$', S ) = 0 ) and TryStrToInt( S, Value );


Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!