如何在excel vba中给出小于一秒的时间延迟? [英] How to give a time delay of less than one second in excel vba?
本文介绍了如何在excel vba中给出小于一秒的时间延迟?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在小于 1 秒的特定持续时间后重复一个事件.我尝试使用以下代码
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")
但是这里的最小延迟时间是一秒.如何给出半秒的延迟?
But here the minimum delay time is one second. How to give a delay of say half a seond?
推荐答案
您可以使用 API 调用和睡眠:
You can use an API call and Sleep:
将其放在模块的顶部:
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
然后你可以在这样的过程中调用它:
Then you can call it in a procedure like this:
Sub test()
Dim i As Long
For i = 1 To 10
Debug.Print Now()
Sleep 500 'wait 0.5 seconds
Next i
End Sub
这篇关于如何在excel vba中给出小于一秒的时间延迟?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文