我希望每10分钟触发一次,由于timer不能达到10分钟触发,看到有用now做触发的,具体怎样做呢,请写入源代码,大家讨论一下。

解决方案 »

  1.   

    Option ExplicitDim T As Long
    Private Sub Form_Load()
        T = 0
        Timer1.Enabled = True
        Timer1.Interval = 60000 '一分钟触发一次
    End SubPrivate Sub Timer1_Timer()
        T = T + 1
        If T = 10 Then MsgBox "时间到", vbInformation
    End Sub
      

  2.   

    Dim Counter As IntegerPrivate Sub Command1_Click()
        If Command1.Caption = "计时开始" Then
            Command1.Caption = "计时结束"
            Counter = 0
            Timer1.Enabled = True
        Else
            Command1.Caption = "计时结束"
            Timer1.Enabled = False
        End If
    End SubPrivate Sub Form_Load()
        Timer1.Interval = 60000
        Timer1.Enabled = False
        Counter = 0
        Command1.Caption = "计时开始"
    End SubPrivate Sub Timer1_Timer()
        Counter = Counter + 1
        Print Counter
        If Counter Mod 10 = 0 Then
            Print "计时一次"
        End If
    End Sub
      

  3.   

    楼上的代码要改进一下:Private Sub Timer1_Timer()
        T = T + 1
        If T = 10 Then 
            MsgBox "时间到", vbInformation
            T=0
        end if  
    End Sub
      

  4.   

    AustinLei(黄瓜杀手) 插队了,我是指的一楼的代码。顺便说一下,AustinLei(黄瓜杀手) 的代码中的counter可能会溢出,还好是1分钟才加1。