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
Related posts:
- How to Pause the application without using Sleep
- How to pause/sleep the application for the given number of milliseconds
- How to handle Size & Position of Console Application with Windows Application in VB6
- How to measure how much time it takes to execute a function or a block of code or event a statement
- VB 2008 Nice Application
- How to add unique items in a collection
- [VB 6.0] Minimiser una application – By H4ckG3n
- How to use Windows Media Player to Play MP3 Files in your application
- How to get windows up time
- How to Start another program using Shell and wait until it finishes.