在VBA中睡眠(整数溢出!) [英] Sleeping in VBA (Integer Overflow!!)

查看:301
本文介绍了在VBA中睡眠(整数溢出!)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在VBA中,您可以

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

为您提供睡眠常规.

但是,对于超过32000毫秒的值,必须传递给例程的Long似乎溢出.

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?

推荐答案

不,它不会溢出,除非您的计算所需毫秒数的代码导致溢出.

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

示例:

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

示例2:

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

这篇关于在VBA中睡眠(整数溢出!)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆