给个思路!!!!
小弟的需求大概是这样的:
目前有在使用一套软件系统,这套系统一天24小时都会在运行,现在想实现这样的功能
当电脑的时间显示为16:00的时候(每天都要做),自动触发一个事件,来记录一些数据,
那这个 "每天16:00的时候触发事件 ",要怎么去实现,需要用到什么技术啊
在线等!!!!!
[解决办法]
用一个timer控件,在timer事件中设置
if hour(now)= "16 " then doYourJob
[解决办法]
楼上正解!
别忘了设置timer控件的Interval属性
[解决办法]
要求很精确么??
如果16.59 触发也无所谓的话别就把时钟间隔尽可能做大些以此节省资源
如果一定要16:00的话,就把时间间隔做成1000
每秒判断,如果是16:00 就执行!
if hour(now)=0 and Minute(now)=0 and Second(now)=0 then doYourJob
[解决办法]
Option Explicit
Private Declare Function SetTimer Lib "user32 " (ByVal hwnd As Long, _
ByVal nIDEvent As Long, _
ByVal uElapse As Long, _
ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib "user32 " (ByVal hwnd As Long, _
ByVal nIDEvent As Long) As Long
Private m_lTimer As Long
Private Sub Timer_Proc(ByVal lngHwnd As Long, _
ByVal nIDEvent As Long, _
ByVal uElapse As Long, _
ByVal lpTimerFunc As Long)
'/* timer return
On Error GoTo Handler
‘你的任务在这里处理
Exit Sub
Handler:
Kill_Timer
End Sub
Public Sub Start_Timer(ByVal lInterval As Long)
'/* start the timer
m_lTimer = SetTimer(0&, 0&, lInterval, AddressOf Timer_Proc)
End Sub
Public Sub Kill_Timer()
'/* kill timer
KillTimer 0&, m_lTimer
End Sub