概述
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 ;
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 ;
转载于:https://www.cnblogs.com/rogee/archive/2010/09/14/1827244.html
最后
以上就是害怕皮皮虾为你收集整理的DELPHI时间触发事件!的全部内容,希望文章能够帮你解决DELPHI时间触发事件!所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复