CryptoSys PKI Pro Manual

Pre-dimensioning for VB6

To create a string of, say, length 40 characters, do either:

Dim sData As String * 40

or

Dim sData As String
sData = String(40, " ")

If you know the output string needs to be the same size as the input, do this:

Dim strInput As String
Dim strOutput As String
strInput = "......"
strOutput = String(Len(strInput), " ")

To create a byte array of a given length:

Dim abData() As Byte
Dim nLen As Long
nLen = 40
ReDim abData(nLen - 1)

Note that byte arrays in VBA are indexed from 0 to nLen - 1, but an array dimensioned as abData(nLen - 1) actually has nLen elements.

To create a byte array of the same length as an existing array, do this:

Dim abOutput() As Byte
ReDim abOutput(Ubound(abInput))
[PREV: Core VBA/VB6 functions vs better wrapper functions...]   [Contents]   [Index]   
   [NEXT: Find length of byte array...]

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