Results 1 to 2 of 2

Thread: Pausing for a time interval without a timer control

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2000
    Posts
    39

    Question

    Any ideas how you can pause a VB program in code without having to reference a timer ? I need to be able to tell the program to not do anything for 5 seconds. I used to be able to do it in C++ with the Wait command I think.

  2. #2
    Guest
    This pauses by the number of seconds
    Code:
    Public Sub Pause(Duration As Double)
        Dim Current As Long
        Current = Timer
        Do Until Timer - Current >= Duration
            DoEvents
        Loop
    End Sub
    
    Private Sub Form_Load()
        Pause 5
    End Sub
    or you can use Sleep which pauses for a number of miliseconds.

    Code:
    Private Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)
    
    Private Sub Form_Load()
        Sleep 5000
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width