Results 1 to 7 of 7

Thread: Delay Code Execution

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Posts
    116

    Exclamation Delay Code Execution

    How can I delay the execution of the next line of
    code for 5 seconds WITHOUT pausing the application?

    Thanks.

    [Edited by VBonliner on 10-13-2000 at 02:44 PM]
    0101011001000010
    01101111011011100110110001101001011011100110010101110010

  2. #2
    Guest
    Add a DoEvents. This will do all the code events before processing to the next line after it.

  3. #3
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357

    Here's an example...

    Code:
    Public Sub Wait(afSeconds As Single)
        Dim lfTimesUp As Single
        Dim llNumDays As Long
        Dim ldDaysUp As Date
        
        lfTimesUp = Timer + afSeconds
        
        Do While lfTimesUp > 86399
            lfTimesUp = lfTimesUp - 86399
            llNumDays = llNumDays + 1
        Loop
        
        ldDaysUp = Date + llNumDays
        
        Do Until Date = ldDaysUp
            DoEvents
        Loop
        
        Do Until Timer >= lfTimesUp
            DoEvents
        Loop
    End Sub
    [Edited by seaweed on 10-13-2000 at 02:59 PM]
    ~seaweed

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Posts
    116
    I have a CLOSE statement after a PRINT statement.
    I need to hold the execution of the CLOSE till
    the printer's 'buffer' gets the document.

    The DoEvents (inbetween PRINT and CLOSE)
    is holding the printer as well and causing problems.

    Any ideas?

    Thanks
    0101011001000010
    01101111011011100110110001101001011011100110010101110010

  5. #5
    Guest
    You shouldn't have any problems with a DoEvents between PRINT and CLOSE. But what is the problem you are having? Because a DoEvents will PRINT and wait for that task to finish and then CLOSE.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Posts
    116
    I am sorry Matthew, the problem is from QUIT application
    not CLOSE document. I tried the DoEvents as below, but
    it didn't work; I still get the message if I wanna
    quit word while a print job is pending.

    PRINT document

    CLOSE document

    DoEvents

    QUIT application

    0101011001000010
    01101111011011100110110001101001011011100110010101110010

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Posts
    116

    Cool

    Thanks Matthew. It worked.
    I placed the DoEvents in a Timer function / Do While
    Loop.
    0101011001000010
    01101111011011100110110001101001011011100110010101110010

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