Kernel32, where are you?

S

stratuser

I've copied some code that refers to procedure within a
DLL called "kernel32" which I seen before somewhere. What
exactly is this DLL? It's not part of VBA, is it? What
is happening when I put this statement at the top of my
module?


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

Rob van Gelder

A Kernel is the core bits and pieces of an Operating System - Windows in
this case.
Simply put, the Kernel acts a go-between for your computer's hardware and
applications.

When you write Declare Sub Sleep at the top of your code, you're telling VBA
that the Sleep Subroutine is found in the Kernel library.

VBA help tells us that Declare references to external procedures in a
dynamic-link library (DLL).
 
S

Steve Garman

Think of the dll as part of windows.

kernel32 contains lots of standard functions which most (probably all)
languages call to do things like sleeping, file and memory handling,
string manipulation, threads, timing etc.

Your declare statement is telling VB exactly what the dll expects as its
argument, so that later in your code when you put
sleep 5000
VB knows to convert the number to a long before calling the sleep function.

Sleep then uses that long as a number of miliseconds to sleep for.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top