I have a sub that receives a byref 2d. dynamic array and a byval string. It switches the string from 'LastName, FirstName' to 'FirstName LastName' to be placed into the dynamic array. I need it to resize the dynamic array one slot bigger and place the new string in it. However I'm having a beast of a time trying to resize my two dimensional array. It will resize the first time but I cant get it to resize on the next run.
Run-time error '9':
Subscript out of range
The procedure works fine as long as I am not preserving the array, but I need to keep the data. On the first run N is 0 and it will resize to a (0,1) array. The second run, N=1, it crashes saying that the subscript is out of range. I have tried many variations of this and keep getting the same result.
-JTBorton
Another Day, Another Disaster
Run-time error '9':
Subscript out of range
Code:
Sub EnterNameValues(ByRef NameList, ByVal strName As String)
On Error Resume Next
N = UBound(NameList)
If Err.Number = 9 Then
N = -1
End If
On Error GoTo 0
N = N + 1
[highlight]ReDim Preserve NameList(N, 1)[/highlight]
N = UBound(NameList)
NameList(N, 0) = SplitName(strName)
.
. (more code jibberish)
.
The procedure works fine as long as I am not preserving the array, but I need to keep the data. On the first run N is 0 and it will resize to a (0,1) array. The second run, N=1, it crashes saying that the subscript is out of range. I have tried many variations of this and keep getting the same result.
-JTBorton
Another Day, Another Disaster