We recommend using Visual Studio 2017
This documentation is archived and is not being maintained.

Argument Data Types

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

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 typeHungarian prefixDescriptionVBA equivalent
BOOLb8-bit Boolean value. Zero indicates False; nonzero indicates True.Boolean or Long
BYTEch8-bit unsigned integer.Byte
HANDLEh32-bit unsigned integer that represents a handle to a Microsoft® Windows® object.Long
intn16-bit signed integer.Integer
longl32-bit signed integer.Long
LPlp32-bit long pointer to a C or C++ structure, string, function, or other data in memory.Long
LPZSTRlpsz32-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