RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
SysUtils.TryStrToInt64 Function

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

Pascal
function TryStrToInt64(const S: string; out Value: Int64): Boolean;
C++
Boolean TryStrToInt64(const AnsiString S, Int64 Value);

SysUtils

TryStrToInt64 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, TryStrToInt64 returns false; otherwise TryStrToInt64 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!