Did you coded or experienced a timer with more then 60 seconds interval
or a timer with maximum cap limit ?
Here it all now :
Functions:-
- Intervals 1 , 5 , 10 and 15 minutes
- Maximum Timer Life 1 , 2 ,3 and infinity hours
Code:
Call the function as This:Code:Public Function StartTimer(bInterval As Double, Optional bMax As Double) Dim MiliCounter As Double, Infinity As Boolean If bMax = 0 Then Infinity = True End If mMax = bMax ‘Maximum Second , -1 for infinity mInterval = bInterval ‘Interval Second MiliCounter = -1 ‘bypass millisecods (timer is for seconds only) StartTime = GetTickCount() ‘Get currunt system timer tick Do While TimerEnabled = True TimePassed = Int((GetTickCount() – StartTime) / 1000) ‘Convert to seconds If Infinity = False Then If TimePassed > mMax Then TimerEnabled = False ‘look for Maximum Second End If If (TimePassed Mod mInterval = 0) And (TimePassed > MiliCounter) Then ‘TimePassed Mod mInterval = 0 ‘look for Interval Second ‘TimePassed > MiliCounter ‘look for next second MiliCounter = TimePassed ‘/////////////Main Interval Code//////////// Debug.Print “time consumed “; TimePassed Call InvokeIntervalEvent ‘/////////////////////////////////////////// End If DoEvents Loop End Function
call StartTimer( 1 * 60, 1 * 3600)
i.e StartTimer for 60 sec intervel and 1 hour life
Happy Coding…
Example is coded in following Post



Reply With Quote
