Results 1 to 3 of 3

Thread: Re: Delay executing

  1. #1
    Guest

    Post

    Without using timer control, what would be the best way to delay execution of code?

    I would like to pause the program for about 1/10 of second before executing th. I could just use For loop to run for, say, 100K times, but I would rather use a function call or so.

    Thanx.

    SK

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    This will do it:
    Code:
        Dim dblEndTime As Double
        
        dblEndTime = Timer + 0.5
        Do While dblEndTime > Timer
          ' Do nothing but allow other
          ' applications to process
          ' their events.
          DoEvents
        Loop
    ------------------
    Marty

  3. #3
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    There is also the Sleep API which will pause your Apps Processes for a Given number of Milliseconds..
    Code:
    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    
    Private Sub Command1_Click()
        Caption = "Ready.."
        Sleep 100   'Pause for 1/10 of a Sec.
        Caption = "Go!!!"
    End Sub
    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]

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