CodeItBetter Programming Another VB Programming Blog

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:

  1. How to Pause the application without using Sleep
  2. How to pause/sleep the application for the given number of milliseconds
  3. How to handle Size & Position of Console Application with Windows Application in VB6
  4. How to measure how much time it takes to execute a function or a block of code or event a statement
  5. VB 2008 Nice Application
  6. How to add unique items in a collection
  7. [VB 6.0] Minimiser una application – By H4ckG3n
  8. How to use Windows Media Player to Play MP3 Files in your application
  9. How to get windows up time
  10. How to Start another program using Shell and wait until it finishes.

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


Trackbacks are disabled.