Declaring & Calling The Sleep API

前端 未结 1 1190
轻奢々
轻奢々 2020-12-11 18:09

I have read many threads on implementing the Sleep API however most are a step ahead of where I am at in terms of knowledge to some guidance would be greatly appreciated.

相关标签:
1条回答
  • 2020-12-11 18:28

    The declaration of Sleep should go to the top of a module. Standard coding module.

    You can omit Call and just use

    Sleep 1000  ' 1 second delay
    

    anywhere within an existing sub, so

    Option Explicit
    
    Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    
    Sub Main()
    
        ' wait 3 seconds
        Sleep 3000
    
    End Sub
    

    enter image description here


    an alternative without declaring the Sleep sub would be

    Application.Wait Now + TimeValue("00:00:03") ' waits 3 seconds
    
    0 讨论(0)
提交回复
热议问题