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))