System.SysUtils.TryStrToUInt64

De RAD Studio API Documentation
Aller à : navigation, rechercher

Delphi

function TryStrToUInt64(const S: string; out Value: UInt64): Boolean;

C++

extern DELPHI_PACKAGE bool __fastcall TryStrToUInt64(const System::UnicodeString S, /* out */ unsigned __int64 &Value)/* overload */;

Propriétés

Type Visibilité  Source Unité  Parent
function public
System.SysUtils.pas
System.SysUtils.hpp
System.SysUtils System.SysUtils


Description

Convertit en nombre une chaîne qui représente un entier (notation décimale ou hexadécimale).

TryStrToUInt64 convertit la chaîne S, qui représente un nombre de type entier en notation décimale ou hexadécimale, en un nombre qui est assigné à Value. Value est exprimé sous la forme d'un entier non signé sur 64 bits. Si S ne représente pas un nombre valide, TryStrToUInt64 renvoie False ; sinon TryStrToUInt64 renvoie True.

TryStrToUInt64 prend en charge les chaînes dans les notations hexadécimales suivantes :

  • Delphi : 0$1234 et 0x1234.
  • C++ : 0x1234.

Pour accepter les valeurs décimales mais pas les valeurs hexadécimales dans la chaîne d'entrée, utilisez un code similaire à celui-ci :

Delphi:
function TryDecimalStrToUInt64( const S: string; out Value: UInt64): Boolean;
begin
  result := (pos('$',S)=0) and ((pos('x',S)=0)) and TryStrToUInt64(S,Value);
end;
C++ :
bool __fastcall TForm1::TryDecimalStrToUInt64(const System::UnicodeString S, unsigned __int64 &Value)
{
  bool result;
  result= (Pos('x',S)==0) && TryStrToUInt64(S,Value);
  return result;
}

Voir aussi