Reputation: 11
I have run the following program on vba excel 2010 32 bit computer :
Declare Sub sleep Lib "kernel32" (ByVal dwmilliseconds As Long)
Sub game()
i = 0
Do
i = i + 1 Cells(i, 1).Interior.Color = RGB(100, 0, 0) sleep 500
Loop Until i > 10
End Sub
But, after running, it shows me the following error :
"Can't find dll entry point sleep in kernel32"
Can somebody please tell me what I should do next to remove the error?
Thanks for the effort.
Upvotes: 1
Views: 1472
Reputation: 564
Instead of sleep 500 you might want to use:
Application.Wait (Now + TimeValue("0:00:05"))
Upvotes: 1
Reputation: 149295
@Transistor is correct. You have to use capital "S". All API declarations are case sensitive.
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
An alternative to Sleep
is to use the function Wait
which I created few years ago and I still use it.
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
Upvotes: 0