Convert Integer Into String
Asked Answered
T

2

29

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?

Treasurehouse answered 31/12, 2009 at 18:9 Comment(3)
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?Hunnicutt
google.pl/… - and you have answer after 1 secProsecute
@inzKulozik, I would love SO to be the first link when someone else googles it!Chancey
C
46

You can use IntToStr:

A:=IntToStr(123)
Chancey answered 31/12, 2009 at 18:11 Comment(0)
M
3

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.

Marleenmarlen answered 14/6, 2015 at 22:35 Comment(1)
Ticks is not an object. You stumbled on the intrinsic record helper for simple types, see Integer Type Helpers.Monsour

© 2022 - 2024 — McMap. All rights reserved.