RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
SysUtils.IntToStr Function

Converts an integer to a string.

Pascal
function IntToStr(Value: Integer): string; overload;
function IntToStr(Value: Int64): string; overload;
C++
AnsiString IntToStr(int Value);
AnsiString IntToStr(Int64 Value);

SysUtils

IntToStr converts an integer into a string containing the decimal representation of that number.  

C++ Examples: 

 

/*
The following example uses two edit controls, a button, and
a label on a form. When the button is clicked, the integers
in the edit controls are multiplied together and the result
is displayed in the label.
*/
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  try
  {
    Label1->Caption = IntToStr(StrToInt(Edit1->Text) * StrToInt(Edit2->Text));
  }
  catch(...)
  {
    ShowMessage("You must specify integer values. Please try again.");
  }
}

 

Delphi Examples: 

{
The following example uses two edit controls, a button, and
a label on a form. When the button is clicked, the integers
in the edit controls are multiplied together and the result
is displayed in the label.
}
procedure TForm1.Button1Click(Sender: TObject);
begin
  try
    Label1.Caption :=
      SysUtils.IntToStr(StrToInt(Edit1.Text) * StrToInt(Edit2.Text));
  except
    ShowMessage('You must specify integer values. Please try again.');
  end;
end;

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!