Is there a way to use join on parts of an array? Like "join( anArray, StartingIndex, LastIndex )?
Or could one slice a big array into subarrays?
Is there a way to use join on parts of an array? Like "join( anArray, StartingIndex, LastIndex )?
Or could one slice a big array into subarrays?
Maybe this :
Function JoinSubArray(anArray() as string, StartingIndex as integer, LastIndex as integer, separator as string) As String
anArray(startingIndex) = "[startToken]"+anArray(startingIndex)
anArray(LastIndex) = anArray(LastIndex)+"[endToken]"
dim result as string = join(anArray, separator)
dim depart as integer = instr(result, "[startToken]")
dim fin as Integer = instr(result, "[endToken]")
return mid(result, depart+12, fin-depart-12)
End Function
msgbox JoinSubArray(myArray, 3, 7, EndOfLine)
I had the same issue a short time ago. The fastest in my case was to loop over the array from startIndex to endIndex and to append the elements to the new (sub-)array. Appending was even faster than creating the sub-array, then using ReDim on it, and loop from startIndex to endIndex while assigning the element.