Sleeping in VBA (Integer Overflow!!)

有些话、适合烂在心里 提交于 2019-12-11 16:23:53

问题


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 consecutive calls to the sleep routine?


回答1:


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


来源:https://stackoverflow.com/questions/2930841/sleeping-in-vba-integer-overflow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!