Argument Data Types

The data types used in C and C++, and the notation used to describe them, differ from those used in Microsoft® Visual Basic® for Applications (VBA). The following table describes some of the common data types used in DLL functions and their VBA equivalents:

C/C++ data type Hungarian prefix Description VBA equivalent
BOOL b 8-bit Boolean value. Zero indicates False; nonzero indicates True. Boolean or Long
BYTE ch 8-bit unsigned integer. Byte
HANDLE h 32-bit unsigned integer that represents a handle to a Microsoft® Windows® object. Long
int n 16-bit signed integer. Integer
long l 32-bit signed integer. Long
LP lp 32-bit long pointer to a C or C++ structure, string, function, or other data in memory. Long
LPZSTR lpsz 32-bit long pointer to a C-type null-terminated string. Long

Although you should be familiar with these data types and their prefixes, the Win32API.txt file mentioned earlier contains Declare statements ready for use in VBA. If you use these Declare statements in your code, the function arguments are defined already with the correct VBA data types.

For the most part, as long as you have defined and passed the correct data types, calling DLL functions works the same way as calling VBA functions. The exceptions are discussed in the following sections.

See Also

Calling DLL Functions | Returning Strings from DLL Functions | Passing User-Defined Types | Using the Any Data Type | Retrieving Error Information Following DLL Function Calls