Dynamic Arrays

Array size is often defined during design time. This type of array is known as static array. However, the problem is sometimes we might not know how many data items we need to store during run time. In this case, we need to use dynamic array where the number of elements will be decided during run time. In Visual Basic 2017, the dynamic array can be resized when the program is executing. The first step in declaring a dynamic array is by using the Dim statement without specifying the dimension list, as follows:

Dim myArray()

Then at run time we can specify the actual array size using the ReDim statement,as follows:

ReDim myArray(n)
* n =array size
You can also declare a two dimensional array using ReDim statement, as follows:

ReDim myArray(n, m)
*mxn indicates the array size.

Read more here

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on RedditEmail this to someone