Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 178
  • Last Modified:

Label changing part 2

Will you give me an EXAMPLE please,  on displaying a new text on a label  every 24 hrs with the aid of a TTimer.
In particular, give an example of a written  OnTImer eventhandler that updates the label caption every 24hrs.

p.s.  Isn't this really easier than 50 points?
0
jjhj
Asked:
jjhj
  • 2
  • 2
1 Solution
 
rene100Commented:
try this (I haven't tested this for 24 hours, just for 1 minute)



unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    btStart: TButton;
    Label1: TLabel;
    procedure Timer1Timer(Sender: TObject);
    procedure btStartClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  PassedTime: Cardinal;
implementation

{$R *.DFM}

procedure TForm1.Timer1Timer(Sender: TObject);
begin
inc(PassedTime); //every minute
if PassedTime=1440 then //after 24 hours (60 * 24);
   begin
   MessageDlg('24 hours passed',mtInformation,[mbok],0);
   label1.caption:='24 hours passed';
   //Here, you can restart this with
   //TimePassed:=0;
end;

procedure TForm1.btStartClick(Sender: TObject);
begin
timer1.interval:=60000; //Sets interval of timer1 to 60000 ms
                        //=1 minute
end;

end.
0
 
pjdbCommented:
If it is in a 32bits program, i think you can give a timer interval of 86400000 (24*60*60*1000) and have your timer working once a day. However, in 16 bits (delphi 1) it will give an overflow.

JDB
0
 
jjhjAuthor Commented:
rene 100

you did a great job!  
if i had extra points to spare i would give em,   however...

thanks bunches, loads , tons, greatly,immensly,weightily,
countlessly,,hugely,                 and frankly    alot.

jjhj
0
 
jjhjAuthor Commented:
rene 100

you did a great job!  
if i had extra points to spare i would give em,   however...

thanks bunches, loads , tons, greatly,immensly,weightily,
countlessly,,hugely,                 and frankly    alot.

jjhj
0
 
rene100Commented:
thanks for the nice comment!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now