CryptoSys PKI Pro Manual

Zero-length byte arrays in VB6/VBA

To create a byte array with zero length do this

Dim abData() As Byte
abData = vbNullString	

There is no simple way to redimension a dynamic array that might have a zero length without risking a runtime error. The best you can do is as follows.

Dim abData() As Byte
Dim nLen as Long
' Compute required length in bytes...
nLen = ComputeLength()  ' returns length, possibly zero
If nLen > 0 Then
    ReDim Preserve abData(nLen - 1)
Else
    abData = vbNullString
End If
[PREV: Find length of byte array...]   [Contents]   [Index]   
   [NEXT: Passing a reference to an empty byte array in VB6/VBA...]

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