Microsoft Office 2000/Visual Basic Programmer's Guide   

Argument Data Types

The data types used in C/C++, and the notation used to describe them, differ from those used in VBA. The following table describes some of the common data types used in DLL functions and their VBA equivalents. This list is not all-inclusive, so if you encounter a data type not described here, check one of the reference sources listed in "Where to Go from Here" at the end of this chapter.

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 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/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 already defined with the correct VBA data types.

For the most part, as long as you've 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.