• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 159
  • Last Modified:

Time Component Question

I have a program that I want to send out a message every 4 hrs.or 6 hrs etc., or whatever the enduser chooses. How can I do this, by using the TTime component?  Or should I use something else.  Please give me an example if you can.

Thanks,
Tony
0
aj85
Asked:
aj85
1 Solution
 
MarcelitoCommented:
You can set the interval property of the TTimer component in miliseconds. 4 hours are 3600000 miliseconds. In the OnTimer event you may put the code that you want execute.

Ej: Is a Form with a TTimer.

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Timer1Timer(Sender: TObject);
begin
                  {Your specific code}
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
    Timer1.Interval:=3600000;     {Set the time that you want}
end;

end.


Good Luck!!!! Send news!!
0
 
puppyCommented:
if you want that the user can change it
then try this:
put a timer
put an edit text
and a button
take the event OnClick of the button
and insert this source:
timer1.Interval:=strtoint(edit1.text);
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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