【问题标题】:Sleep function error 453睡眠功能错误 453
【发布时间】:2014-12-14 03:22:45
【问题描述】:

我在 vba excel 2010 32 位计算机上运行了以下程序:

声明 Sub sleep Lib "kernel32" (ByVal dwmilliseconds As Long)

子游戏()

i = 0

i = i + 1

Cells(i, 1).Interior.Color = RGB(100, 0, 0)
sleep 500  

循环直到 i > 10

结束子

但是,运行后,它显示以下错误:

“在 kernel32 中找不到 dll 入口点休眠”

谁能告诉我下一步我应该怎么做才能消除错误?

感谢您的努力。

【问题讨论】:

  • 在睡眠中尝试大写“S”

标签: excel vba


【解决方案1】:

您可能想要使用 sleep 500 而不是:

Application.Wait (Now + TimeValue("0:00:05"))

【讨论】:

    【解决方案2】:

    @Transistor 是正确的。您必须使用大写“S”。所有 API 声明都区分大小写。

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

    Sleep 的替代方法是使用我几年前创建的函数 Wait,现在我仍在使用它。

    Sub Sample()
        i = 0
        Do
            i = i + 1
            Cells(i, 1).Interior.Color = RGB(100, 0, 0)
            Wait 1
        Loop Until i > 10
    End Sub
    
    Private Sub Wait(ByVal nSec As Long)
        nSec = nSec + Timer
        While nSec > Timer
            DoEvents
        Wend
    End Sub
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-12
      • 2011-04-08
      • 2011-02-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多