DELPHI时间触发事件!

1 procedure TForm1.Timer2Timer(Sender: TObject);

2 //delphi 时间触发事件

3 var

4 S,D:TDateTime;

5 ActiveHH:string;//触发小时

6 ActiveMM:string;//触发分

7 ActiveSS:string;//触发秒

8 begin

9 s:=strtodatetime(FormatDateTime('hh:mm:ss',Now));//时间

10

11 ActiveHH :=Edit3.Text;//时

12 ActiveMM :=Edit4.Text;//分

13 ActiveSS :=Edit5.Text; //秒

14

15

16 D:=strtodatetime(ActiveHH +':' + ActiveMM + ':' + ActiveSS); //到时间

17

18 //当日期为当天就触发

19 if FormatDateTime('YYYY-MM-DD ',DateTimePicker2.date) = FormatDateTime('YYYY-MM-DD ',now) then

20 begin

21 if s=d then //当时间一样就触发

22 begin

23 showmessage('电脑爆了!');

24 // 这中间你加入你自己要 执行的数据库语句

25 end;

26 end;

27

28 end;