小弟的需求大概是这样的:
目前有在使用一套软件系统,这套系统一天24小时都会在运行,现在想实现这样的功能
当电脑的时间显示为16:00的时候(每天都要做),自动触发一个事件,来记录一些数据,
那这个"每天16:00的时候触发事件",要怎么去实现,需要用到什么技术啊
在线等!!!!!

解决方案 »

  1.   

    用一个timer控件,在timer事件中设置
    if hour(now)="16" then doYourJob
      

  2.   

    Private Sub Timer1_Timer()
        Static done As Boolean
        If done = False And Hour(Now) = "11" Then
            MsgBox "do something"
            done = True
        End If
        
    End Sub
      

  3.   

    楼上正解!
    别忘了设置timer控件的Interval属性
      

  4.   

    要求很精确么??如果16.59 触发也无所谓的话别就把时钟间隔尽可能做大些以此节省资源如果一定要16:00的话,就把时间间隔做成1000
    每秒判断,如果是16:00 就执行!if hour(now)=0 and Minute(now)=0 and Second(now)=0 then doYourJob
      

  5.   

    Option ExplicitPrivate Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, _
                                                    ByVal nIDEvent As Long, _
                                                    ByVal uElapse As Long, _
                                                    ByVal lpTimerFunc As Long) As LongPrivate Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, _
                                                     ByVal nIDEvent As Long) As Long
    Private m_lTimer        As LongPrivate Sub Timer_Proc(ByVal lngHwnd As Long, _
                           ByVal nIDEvent As Long, _
                           ByVal uElapse As Long, _
                           ByVal lpTimerFunc As Long)'/* timer returnOn Error GoTo Handler‘你的任务在这里处理
    Exit SubHandler:
        Kill_TimerEnd SubPublic Sub Start_Timer(ByVal lInterval As Long)
    '/* start the timer    m_lTimer = SetTimer(0&, 0&, lInterval, AddressOf Timer_Proc)End SubPublic Sub Kill_Timer()
    '/* kill timer    KillTimer 0&, m_lTimerEnd Sub
      

  6.   

    谢谢各位了
    这些办法确实不错
    但是现在公司决定让DBA写个脚本,每天自动去运行一条SQL语句
    咳!!