chrispybee
Technical User
I have a wait routine that maxs out my CPU while it waits.
Is there another way of waiting #seconds without maxing out my cpu. I've tried the following.
Example 1:
Public Sub Wait(sec As Single)
Dim tim As Single
tim = Timer
While Timer < tim + sec
DoEvents
Wend
End Sub
Usage: wait 1' Wait 1 second
Example 2:
Sec = Second(Time) + 5
Do Until (Second(Time) >= Sec)
DoEvents
Loop
MsgBox "This is done.."
End
The problems that I have are the following...
1. Crashs application after 7 - 10 hours
2. CPU Usage is 100% when waiting
Any help would be great. I dont know how to use timers, so help on this would also be great.
Novice when comes to these sort of routines.
Is there another way of waiting #seconds without maxing out my cpu. I've tried the following.
Example 1:
Public Sub Wait(sec As Single)
Dim tim As Single
tim = Timer
While Timer < tim + sec
DoEvents
Wend
End Sub
Usage: wait 1' Wait 1 second
Example 2:
Sec = Second(Time) + 5
Do Until (Second(Time) >= Sec)
DoEvents
Loop
MsgBox "This is done.."
End
The problems that I have are the following...
1. Crashs application after 7 - 10 hours
2. CPU Usage is 100% when waiting
Any help would be great. I dont know how to use timers, so help on this would also be great.
Novice when comes to these sort of routines.