The procedures in DLLs are most commonly documented using C language syntax. To call these procedures from Visual Basic, you need to translate them into valid Declare statements and call them with the correct arguments.
As part of this translation, you must convert the C data types into Visual Basic data types and specify whether each argument should be called by value (ByVal) or implicitly, by reference (ByRef). The following table lists common C language data types and their Visual Basic equivalents for 32-bit versions of Windows.
C language data type | In Visual Basic declare as | Call with |
ATOM | ByVal variable As Integer | An expression that evaluates to an Integer |
BOOL | ByVal variable As Long | An expression that evaluates to a Long |
BYTE | ByVal variable As Byte | An expression that evaluates to a Byte |
CHAR | ByVal variable As Byte | An expression that evaluates to a Byte |
COLORREF | ByVal variable As Long | An expression that evaluates to a Long |
DWORD | ByVal variable As Long | An expression that evaluates to a Long |
HWND, HDC, HMENU, etc. (Windows handles) | ByVal variable As Long | An expression that evaluates to a Long |
INT, UINT | ByVal variable As Long | An expression that evaluates to a Long |
LONG | ByVal variable As Long | An expression that evaluates to a Long |
LPARAM | ByVal variable As Long | An expression that evaluates to a Long |
LPDWORD | variable As Long | An expression that evaluates to a Long |
LPINT, LPUINT | variable As Long | An expression that evaluates to a Long |
LPRECT | variable As type | Any variable of that user-defined type |
LPSTR, LPCSTR | ByVal variable As String | An expression that evaluates to a String |
LPVOID | variable As Any | Any variable (use ByVal when passing a string) |
LPWORD | variable As Integer | An expression that evaluates to an Integer |
LRESULT | ByVal variable As Long | An expression that evaluates to a Long |
NULL | As Any or ByVal variable As Long |
ByVal Nothing or ByVal 0& or vbNullString |
SHORT | ByVal variable As Integer | An expression that evaluates to an Integer |
VOID | Sub procedure | Not applicable |
WORD | ByVal variable As Integer | An expression that evaluates to an Integer |
WPARAM | ByVal variable As Long | An expression that evaluates to a Long |