CryptoSys PKI Toolkit Manual

Pre-dimensioning for VB

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 VB are indexed from 0 to nLen - 1.

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

Dim abOutput() As Byte
ReDim abOutput(Ubound(abInput))

To find the length of an existing byte array:

nLen = UBound(abData) - LBound(abData) + 1

Be careful, as this will cause a run-time error if abData() has not been ReDim'd. Look at the code for the function cnvHexStrFromBytes in basCrPKI.bas to see how this can be handled.

Other Issues For VB6/VBA Users

[Contents] [Index]

[HOME]   [NEXT: Using with C and C++...]

Copyright © 2004-9 D.I. Management Services Pty Ltd. All rights reserved.