开发者

Sleeping in VBA (Integer Overflow!!)

开发者 https://www.devze.com 2023-01-02 00:10 出处:网络
In VBA you can Declare Sub Sleep Lib \"kernel32\" (ByVal dwMilliseconds As Long) to provide yourself with a sleep routine.

In VBA you can

Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

to provide yourself with a sleep routine.

However, the Long that must be passed to the routine appears to overflow for values in excess of 32000 milliseconds.

Is there a way to sleep for longer periods of time without the complexity of stringing together several co开发者_开发技巧nsecutive calls to the sleep routine?


No, it doesn't overflow, unless your code that calculates required number of milliseconds causes an overflow.

Example:

dim t as long
t = 10000 * 10000 / 10000 'Overflow

Example 2:

dim t as long
t = 10000! * 10000 / 10000 'Ok
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号