请教各位大虾,在VB中,timer控件的时间间隔(Interval)属性值最大是不是不能超过1分钟(60000)啊?还是能更大?

解决方案 »

  1.   

    允许长延时的 Timer, 长达 49 天以上。'模块中代码
    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(5000) '5 seconds
      

  2.   

    楼上的,我试了一下,在VB中怎么不认“AddressOf”啊,你提供的方式不能用啊,怎么解决阿
      

  3.   

    用纯 VB 实现长时间定时Private Sub Form_Load()
        Timer1.Interval = 60000
        Timer1.Enabled = True
    End SubPrivate Sub Timer1_Timer()
        Static s_Minutes As Long
        
        s_Minutes = s_Minutes + 1
        If s_Minutes = 60 Then
            s_Minutes = 0
            Debug.Print "一小时到了"
        End If
    End Sub
      

  4.   

    严重同意Tiger_Zhao(VB老鸟),虽然没仔细看他的程序,但是使用VB带的方法,再加那么一点点编程技巧完全可以解决很多问题,不必去搞那么一大堆API。把VB都写得不象VB了。
      

  5.   

    Private Sub Form_Load()
    Timer1.Interval = 60000
    Timer1.Tag = "0"
    End Sub
    Private Sub Timer1_Timer()
    If Timer1.Tag > "60" Then
        Timer1.Tag = "0"
       
        '这里就写你代码
    Else
        Timer1.Tag = Trim(Str(Val(Timer1.Tag) + 1 ))
    End If
    End Sub
    在别处看到的,但是我对Timer1.Tag = Trim(Str(Val(Timer1.Tag) + 1 ))
    还是不能理解.
      

  6.   

    Tiger_Zhao(VB老鸟), 方法不错
      

  7.   

    有这么复杂吗?前天正好写了个聊天室的自动泡点程序=_=,有用到,两句搞定啊Private Sub Timer1_Timer()’Timer1.Interval 设置的是30000,即30秒
    Static iii As Longiii = iii + 1If iii >= 20 Then ' 我要泡的那个聊天室要求20分钟内必须发言,我设置的是30秒 X 20 = 10分钟发言一次'要调用的函数iii = 0 '清零,重新记数End IfEnd Sub
    测试通过,天天晚上挂机泡点呢HOHO