Afficher : Delphi
C++
Préférences d'affichage
System.SysUtils.TryStrToInt
De XE2 API Documentation
Delphi
function TryStrToInt(const S: string; out Value: Integer): Boolean;
C++
extern PACKAGE bool __fastcall TryStrToInt(const System::UnicodeString S, /* out */ int &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 (décimal ou hexadécimal), avec renvoi d'un code de succès booléen.
TryStrToInt convertit la chaîne AnsiStringS, qui représente un nombre entier, en notation décimale ou hexadécimale, affecté à Value. Si S ne représente pas un nombre valide, TryStrToInt renvoie False, sinon TryStrToInt renvoie True.
Pour accepter les valeurs décimales et pas les valeurs hexadécimales dans la chaîne de saisie, utilisez un code similaire à celui-ci :
function TryDecimalStrToInt( const S: string; out Value: Integer): Boolean;
begin
result := ( pos( '$', S ) = 0 ) and TryStrToInt( S, Value );
end;