System.SysUtils.TryStrToInt64

提供: RAD Studio API Documentation
移動先: 案内検索

Delphi

function TryStrToInt64(const S: string; out Value: Int64): Boolean;

C++

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

プロパティ

種類 可視性 ソース ユニット
function public
System.SysUtils.pas
System.SysUtils.hpp
System.SysUtils System.SysUtils


説明

整数を表す文字列(10 進または 16 進表記)を数値に変換します。

TryStrToInt64 は、10 進か 16 進の整数型数値を表す文字列 S を数値に変換し、Value に代入します。値は 64 ビット整数として表されます。S が有効な数値を表していない場合、TryStrToInt64 は False を返します。そうでない場合、TryStrToInt64 は True を返します。

TryStrToInt64 では、以下の 16 進表記の文字列をサポートしています。

  • Delphi の場合: 0$1234 および 0x1234
  • C++ の場合: 0x1234


入力文字列として 16 進値ではなく 10 進値のみ指定可能とするには、以下のようなコードを使用してもかまいません。

Delphi の場合:
function TryDecimalStrToInt64( const S: string; out Value: Int64): Boolean;
begin
  result := (pos('$',S)=0) and ((pos('x',S)=0)) and TryStrToInt64(S,Value);
end;
C++ の場合:
bool __fastcall TForm1::TryDecimalStrToInt64(const System::UnicodeString S, __int64 &Value)
{
  bool result;
  result= (Pos('x',S)==0) && TryStrToInt64(S,Value);
  return result;
}

関連項目