Hi,
I'm trying to ReDim and Preserve a dynamic mulitidimensional array but it's keeps giving me the subscript out of range error.
It is a 2 dimensional array. I now the size of the 2nd dimension but not the 1st. So I'm trying to redim it as follows:
The above code works fine when I "pre" dimension the multidimensional array but as I said earlier, I need to dynamically redim the first dimension based on how many items are currently selected..Code:Dim sArray() as String Dim nCnt as Integer Dim nSub as Integer For nSub = 1 To ListView1.ListItems.Count ReDim Preserve sArray(nCnt, 3) sArray(nCnt, 0) = ListView1.ListItems(nSub).Key sArray(nCnt, 1) = ListView1.ListItems(nSub).SubItems(1) ... nCnt = nCnt + 1 Next
I just read in MSDN, that "Only the upper bound of the last dimension can be changed when you use the Preserve keyword." Is that the problem I'm running into? Is it not possible to ReDim and Preserve the 1st dimension in a multidimensional array?
Any help would be appreciated..
Dan




Reply With Quote