< Previous lesson | Table of Content | Content of this Chapter | Next lesson >

Dynamic Array

Type the following code


Dim DynArray() As Integer
Dim i As Integer
Dim k As Integer
For i = 4 To 10
k = k + 1
ReDim Preserve DynArray(k)
DynArray(k) = i
Next i
Me.Print UBound(DynArray)


1. Debug the value of DynArray
2. Remove the keyword Preserve and debug the value of DynArray .
3. What is your conclusion on the usage of keyword Preserve ?
4. Check why the following code does not work and fixed it.

Dim DynArray() as Integer
Dim i as Integer
Dim k as Integer
For i = 1 to 10
k = UBound(DynArray) + 1
ReDim Preserve DynArray(k)
DynArray(k)=i
Next i

< Previous lesson | Table of Content | Content of this Chapter | Next lesson >