CryptoSys API Library 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 "diCryptoSys.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 library, 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. This manual has now been edited to suit.

Note: Passing a null (empty) array to a VBA wrapper function is different, e.g. cipherEncryptBytes, where the parameter is of type lpInput() As Byte. See Empty byte arrays for VBA wrappers below.

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

Copyright © 2001-24 D.I. Management Services Pty Ltd. All rights reserved. Generated 2024-01-07T07:42:00Z.