vb6的time控件,Interval属性最大也就设定1分半运行一次,怎么才能设定10分钟运行一次,直接设定time.interval = 600000,运行的时候显示错误

解决方案 »

  1.   

    0分贴,BS LZ
    用settimer
    或datetime计算
      

  2.   

    用timeSetEvent函数: http://blog.csdn.net/chenjl1031/archive/2008/01/09/2032579.aspx
      

  3.   

    反正用哪个API都要子类化的了,为了一个定时器而子类化的话,不值得。除非你的程序还有其他功能需要用到子类化。要不楼主可以简单点,把Timer控件的Interval属性设置为1000,再用一个模块级或者静态变量来记录重复次数,当达到要求次数后,再执行代码'10分钟的话应该是600秒
    Const TENMINUTE = 600Private Sub Form_Load()
        Timer1.Interval = 1000
        Timer1 = True
    End SubPrivate Sub Timer1_Timer()
        Static lngCount As Long
        If lngCount = TEMMINUTE Then
            '这里添加代码
             '代码执行后,记得把记数器清零
             lngCount = 0
        Else
            lngCount = lngCount + 1
        End If
    End Sub
      

  4.   

    超长 Timer 代码,可以定时 47 天。'模块中代码
    Dim lTimerId As Long
    Private 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 LongPrivate Sub TimerProc(ByVal lHwnd As Long, ByVal lMsg As Long, ByVal lTimerId As Long, ByVal lTime As Long)Dim lResult As Long
    lResult = StopTimer(lTimerId)
    Call InsertYourProcessNameHere
    'code to be executed after interval
    End SubPublic Sub StartTimer(lInterval As Long) 'convert interval to milliseconds prior to passing
    lTimerId = SetTimer(0, 0, lInterval, AddressOf TimerProc)
    End SubPublic Function StopTimer(lTimerId As Long) As Long
    'must pass the TimerId returned by SetTimer
    StopTimer = KillTimer(0, lTimerId)
    End Function'调用方式
    Call StartTimer(600000) '600 seconds