简单示例 Dim int状态 As Long Dim intSecond As LongPrivate Sub Form_Load() Timer1.Interval = 1000 Timer1.Enabled = True End SubPrivate Sub Timer1_Timer() intSecond = intSecond + 1 If intSecond > 6000 And return状态 < 10 Then Timer1.Enabled = False MsgBox "报错" ElseIf intSecond > 6000 And return状态 > 10 Then '正常执行完毕 Timer1.Enabled = False End If End Sub Function return状态() As Long return状态 = int状态 End Function
Private Sub Form_Load() Timer1.Interval = 1000 Timer1.Enabled = false End SubPrivate Sub command1_click() 按下开始监测按钮 Timer1.Enabled = True if functionA()=true then '设检测状态值的函数为functionA。 如果开始即为高,是不是该进行一下异常处理。 end if End SubPrivate Sub Timer1_Timer() Timer1.Enabled = false if functionA()=false then msgbox "出错" end if end sub
Dim int状态 As Long
Dim intSecond As LongPrivate Sub Form_Load()
Timer1.Interval = 1000
Timer1.Enabled = True
End SubPrivate Sub Timer1_Timer()
intSecond = intSecond + 1
If intSecond > 6000 And return状态 < 10 Then
Timer1.Enabled = False
MsgBox "报错"
ElseIf intSecond > 6000 And return状态 > 10 Then
'正常执行完毕
Timer1.Enabled = False
End If
End Sub
Function return状态() As Long
return状态 = int状态
End Function
Timer1.Interval = 1000
Timer1.Enabled = false
End SubPrivate Sub command1_click() 按下开始监测按钮
Timer1.Enabled = True
if functionA()=true then '设检测状态值的函数为functionA。
如果开始即为高,是不是该进行一下异常处理。
end if
End SubPrivate Sub Timer1_Timer()
Timer1.Enabled = false
if functionA()=false then
msgbox "出错"
end if
end sub
你可以自己写个计数的函数