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;
Boolean TryStrToInt(const AnsiString S, int Value);
SysUtils
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; begin result := ( pos( '$', S ) = 0 ) and TryStrToInt( S, Value ); end;
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|