user3211668
user3211668

Reputation: 53

Delphi 7 - How to convert an Integer to a String

I need my Label to read the percentage of the progressbar. For example if the progressbar is at 13% i need my Label to display 13, if it is at 76% I need it to display 76.

Label1.Caption := ...

What do i do?

Upvotes: 0

Views: 4974

Answers (1)

David Heffernan
David Heffernan

Reputation: 613192

It sounds like you are simply asking how to convert an integer to a string. Use IntToStr for that. For instance,

Label1.Caption := IntToStr(ProgressBar1.Position);

This assumes that MinValue is 0 and MaxValue is 100. Otherwise the calculation for the percentage would be:

Percent := MulDiv(
  ProgressBar1.Position - ProgressBar1.MinValue,
  100,
  ProgressBar1.MaxValue - ProgressBar1.MinValue
);

Upvotes: 2

Related Questions