How to Pause our application
Posted on July 6, 2010
Sometimes we might require to pause our application for some time. like there might be other processes which needs to be completed before our application proceeds further. There are few ways to achieve that. Here is one of the way to pause or wait our application:
Instructions:
- Create a new Project
- Add a new module to it and name it as Module1
Now, copy the following code to Module1:
1 2 3 4 5 6 7 8 9 10 11 12 | Option Explicit Declare Function GetTickCount Lib "kernel32" () As Long Sub Wait(ByVal dwMilliseconds As Long) Dim StartTime As Long StartTime = GetTickCount Do Debug.Print "Waiting ..." DoEvents Loop Until (GetTickCount - StartTime) > dwMilliseconds End Sub |
How to call this function:
1 2 3 4 5 | Option Explicit Sub Main() Call Wait(1000) 'this will pause/wait our application for 1 min (1000 milliseconds) End Sub |
This function uses GetTickCount API function.
If you have any questions, please post as a comment. Thanks