How to give a time delay of less than one second in excel vba?

后端 未结 10 2140
孤街浪徒
孤街浪徒 2020-11-29 06:14

i want to repeat an event after a certain duration that is less than 1 second. I tried using the following code

Application.wait Now + TimeValue (\"00:00:01\         


        
10条回答
  •  独厮守ぢ
    2020-11-29 06:52

    I have try this and it works for me:

    Private Sub DelayMs(ms As Long)
        Debug.Print TimeValue(Now)
        Application.Wait (Now + (ms * 0.00000001))
        Debug.Print TimeValue(Now)
    End Sub
    
    Private Sub test()
        Call DelayMs (2000)  'test code with delay of 2 seconds, see debug window
    End Sub
    

提交回复
热议问题