Recent

Author Topic: [solved] Want to display a count that increments in a TLabel box.  (Read 2127 times)

trat50

  • Newbie
  • Posts: 2
I am trying to display an integer count in a TLabel box.

The problem is the TLabel displays nothing and then 7..  but no numbers in between.
I have inserted sleep() commands to slow things down long enough to see this count.
That is how I know the TLabel box is displaying nothing and then 7, and nothing else.

So why doesn't the TLabel box display 0, and then 1, and then 2, and then 3.. up to 7?

I had a similar problem programming in Gambas3.  Solved it by using the "Delay" function.
The Delay function processes all pending events and returns immediately.
« Last Edit: November 23, 2014, 05:01:28 pm by trat50 »

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Want to display a count that increments in a TLabel box.
« Reply #1 on: November 23, 2014, 10:03:35 am »
Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);
begin
  sleep(15);
  for count:= 1 to 7 do
  begin
    stringcount := IntToStr(count);
    Label3.Caption:=stringcount;
    windows.beep(800,500); sleep(19);
    windows.beep(300,500);  sleep(19);
    windows.beep(800,500);  sleep(19);
    windows.beep(300,500);  sleep(119);
    Application.ProcessMessages;
  end;
end;

trat50

  • Newbie
  • Posts: 2
Re: Want to display a count that increments in a TLabel box.
« Reply #2 on: November 23, 2014, 04:56:58 pm »
Thank you howardpc, that works great!  :)

 

TinyPortal © 2005-2018