Results 1 to 5 of 5

Thread: How to Use Sleep Function in VB??

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2000
    Posts
    23

    Question

    Hi
    How to use Sleep Function In VB?? Any help on this?
    thanks in advance
    Karthik K

  2. #2
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987
    You just need to declare the API call as such...

    Code:
    Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)
    and implement it in this way..

    Code:
    Sleep 500 ' Causes application to stop for 500 milliseconds
    It's as simple as that, you just have to be careful using the Sleep function in your apps because while it is 'sleeping' you will not be able to performs other events and such until it is completed and it may cause your application to be recognized as being idle (thanks Chris )
    {Insert random techno-babble here}

    {Insert quote from some long gone mofo here}

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Sep 2000
    Posts
    23

    Exclamation How to use that

    Hi
    Thanks for the help. But how to use that Seconds..I mean I cant add more number of Zeros ..
    Karthik
    Thanks

  4. #4
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987
    Code:
     
    Sleep 1000 ' equal to 1 second
    Not quite sure what you are asking but 1000 milliseconds is equal to 1 second.
    {Insert random techno-babble here}

    {Insert quote from some long gone mofo here}

  5. #5
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    If you want a second-based (not millisecond-based) delay, that doesn't freeze your application while it's delaying:
    Code:
    Sub Delay(ByVal nSeconds As Single)
        Dim nStart As Single
        
        nStart = Timer
        
        Do
            DoEvents
        Loop Until Timer - nStart >= nSeconds
    End Sub
    To use:
    Code:
    Call Delay(17) ' Wait 17 seconds
    Call Delay(1.5) ' Wait 1 second + 500 milliseconds
    ' etc.

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