I am sending a double-precision array, x(), to the subroutine listed below, and dimensioning ndx() based on the length of x(), which I obtain from x.GetLength(0) - 1.
However, occasionally the loop hangs because ndx() is a shorter length based on use in a previous subroutine. Therefore, it seems that the Redim ndx(n) statement does not always force the redimensioning to occur.
Public Sub processx(ByVal x)
Dim i As Integer
Dim n As Integer = x.GetLength(0) - 1
Array.Clear(arr, 0, UBound(arr))
Array.Clear(ndx, 0, UBound(ndx))
For i = 1 To n
arr(i) = x(i)
ndx(i) = i