VB中如何实现每150分钟运行一个过程?用Timer好象不行。

解决方案 »

  1.   

    Option Explicit
        Dim sum As Long
    Private Sub Form_Load()
        Timer1.Interval = 500
    End SubPrivate Sub Timer1_Timer()
        If lbltime.Caption <> CStr(Time) Then
            sum = sum + 1
            If sum >= 9000 Then
                sum = sum - 9000
                lbltime.Caption = "时间到"
                '执行过程代码
            End If
        End If
    End Sub
      

  2.   

    与一楼一样,只是最好把一个当前时间存下来(至于存哪里LZ自己考虑)Option Explicit
    Dim Nowtime As datePrivate Sub Form_Load()
        Timer1.Interval = 500
    End SubPrivate Sub Timer1_Timer()
        If addtime(Nowtime,9000) < format(now,"yyyy-mm-dd hh:mm:ss") Then
              Nowtime=format(now,"yyyy-mm-dd hh:mm:ss")
              '执行过程代码
        End If
    End Sub