ReDim array but keep the values

Viewed 6220

Suppose I have a code like this:

Dim resultArray() As Double
ReDim resultArray(1 to 10) As Double

Dim i As Integer
For i = 1 to 10 
  resultArray(i) = i
Next

ReDim resultArray(1 to 20) As Double
For i = 11 To 20
 resultArray(i) = i
Next

Is code like this possible? Would the values from the first cycle remain in the array?

I don't know the length of an array. 20 is just a number, which I won't know until the very end of the program.

2 Answers
Related