NULL
argument in C is to use ByVal 0&
.
Do not use vbNull
. vbNull
is not the VBA equivalent of NULL
in C§.
For example, given the following definition
Public Declare Function FOO_Bar Lib "diCrPKI.dll" (ByRef lpOutput As Byte, ByVal nOutBytes As Long, ...) As Long
the correct way to pass a "NULL" pointer for parameter lpOutput is as follows
nRet = FOO_Bar(ByVal 0&, 0, ...) ' Strictly correct
In this Toolkit, it is generally sufficient to set nOutBytes to be 0 and the corresponding lpOutput argument will be ignored. So the following is sufficient.
nRet = FOO_Bar(0, 0, ...) ' OK
§ We admit we have used vbNull
in examples for years, believing it to be the equivalent of NULL
in C.
Fortunately none of the examples caused a problem because if the length is also set to zero then it is ignored.
[Changed in v12.1] This manual has now been edited to suit.