Convert Integer Into String

60,021

Solution 1

You can use IntToStr:

A:=IntToStr(123)

Solution 2

I just did my first steps with a 30day test version of Delphi XE8 and figured out that one has to write e.g.

  Ticks: integer;
  LabelTicks: TLabel;
  (...)
  LabelTicks.Text:= System.SysUtils.IntToStr( Ticks);

But: The variable 'Ticks' seems to be an object! I did not expect that, but you can also write

  LabelTicks.Text:= Ticks.ToString;

To me that seems to be much more elegant.

Share:
60,021

Related videos on Youtube

Nathan Campos
Author by

Nathan Campos

Electrical Engineer, Ham radio operator, photographer, used to be a programmer.

Updated on June 15, 2020

Comments

  • Nathan Campos
    Nathan Campos almost 4 years

    I have a some numbers stored in a Integer called mode, but I need to use they in a TProcess. For this I need to convert the Integer into a String, because if I don't do this, I got the error:

    Incompatible types: got "LongInt" expected "AnsiString"

    Then I want to know how I can convert a Integer into a String?

    • Rob Kennedy
      Rob Kennedy over 14 years
      I'd like the two people who voted down this question to come forward. What's not useful about this question? Is it unclear? What part of No question is too trivial or too "newbie" do you not understand?
    • inzKulozik
      inzKulozik over 14 years
      google.pl/… - and you have answer after 1 sec
    • notnoop
      notnoop over 14 years
      @inzKulozik, I would love SO to be the first link when someone else googles it!
  • LU RD
    LU RD almost 9 years
    Ticks is not an object. You stumbled on the intrinsic record helper for simple types, see Integer Type Helpers.