Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pausing subroutine

Status
Not open for further replies.

billheathco

Electrical
Sep 17, 2015
1
Public Declare Function GetTickCount Lib "kernel32" () As Long

Public Sub wait(ByVal dblMilliseconds As Double)
Dim dblStart As Double
Dim dblEnd As Double
Dim dblTickCount As Double

dblTickCount = GetTickCount()
dblStart = GetTickCount()
dblEnd = GetTickCount + dblMilliseconds

Do
DoEvents
dblTickCount = GetTickCount()
Loop Until dblTickCount > dblEnd Or dblTickCount < dblStart


End Sub

I found this in another post and it works. However, when I tried to use it, I found that all execution in any other subroutine also stops. I need to stop processing the current routine while others complete. Any help would be appreciated.
 
Replies continue below

Recommended for you

You could use Sleep

Code:
Public Declare sub Sleep Lib "kernel32" (ByVal ms as Long)

Public Sub wait(ByVal ms As long)
   for count = 0 to ms step 100
      DoEvents
      Sleep 100
   next
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor