vb6 how to resize dynamic arrays
<p>In vb6 I have an dynamic array defined like this because I don't know how many values to be added while running the program</p>

<pre><code>Private myrray() As String
</code></pre>

<p>Now I have problems to redimension this array. I have tried to following</p>

<pre><code>Dim Upper As Integer
Upper = UBound(myArray) ' here I get the runtime error
If Err.Number Then
  Upper = 0
Else
Upper = UBound(myArray) + 1
End If
</code></pre>

<p>The problem is that the <strong>upper()</strong>-function always gives me <strong>runtime-error 9 "index outside the valid area</strong></p>

<p>I also tried an other way, here I become the same error but in the else-Block:</p>

<pre><code>Dim Upper As Integer
If IsEmpty(myArray) Then
  Upper = 0
Else
  Upper = UBound(myArray) + 1 'here I get the same error in this line
End If
</code></pre>

<p>Later I will use <strong>Upper</strong> to redimensionze my array like this to add a new value:</p>

<pre><code>ReDim Preserve myArray(Upper)
myArray(Upper) = "new text"
</code></pre>

<p>Does anyone know why and how I can solve this problem or tell me an other way to redimensionize an array?</p>