CryptoSys PKI Pro Manual

Passing a reference to an empty byte array in VB6/VBA

The equivalent in VBA/VB6 of passing a 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.

[PREV: Zero-length byte arrays in VB6/VBA...]   [Contents]   [Index]   
   [NEXT: Other Issues For VB6/VBA Users...]

Copyright © 2004-24 D.I. Management Services Pty Ltd. All rights reserved. Generated 2024-09-23T07:52:09Z.