Consulting

Results 1 to 2 of 2

Thread: code executing too fast?

  1. #1
    VBAX Tutor MINCUS1308's Avatar
    Joined
    Jun 2014
    Location
    UNDER MY DESK
    Posts
    254

    code executing too fast?

    Im just curious.....

    'WHY DO THESE RESULT IN A DIFFERENT OUTPUT?
    
    
    Sub ONE()
        For i = 1 To 4
            Application.Wait (Now + TimeValue("0:00:01"))
            Beep
        Next i
    End Sub
    
    
    Sub TWO()
        Beep
        Beep
        Beep
        Beep
    End Sub
    - I HAVE NO IDEA WHAT I'M DOING

  2. #2
    Because in sub one, you have a application.wait command with a time value of 1 second.
    So it's going to run though the code, wait one second, and then run through the rest of the code.. then repeat loop.

    Sub two is doing all 4 beeps... but because it's going so fast, it only appears that your hearing one.

Posting Permissions

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