34,333
edits
Changes
no edit summary
'''Dim''' ''arrayname(size)'' '''As''' ''dataType''
The ''arrayname'' is the name by which the arrray array will referenced in code. The ''size'' value in parentheses defines the maximum size of the array. It is important to note that arrays elements are numbered starting from 0, so an array of size 10 actually holds 11 elements (indexed as 0 though to 10).
Finally, the ''dataType'' value defines the type of variable the array will hold.
== Changing the Size of a Visual Basic Array ==
Once an array has been declared, its size can be changed using either a destructive or non-destructing approach. The Visual Basic ''ReDim'' keyword destroys the array and tyhen then recreates it thus losing any data held in the array. ''ReDim'' is useful for re-using an existing array, but of little use in terms of dynamically resizing that array since all data is lost.
The following Visual Basic code destructively changes the size of an array:
</pre>
The Visual Basic ''Array.Reverse()'' function may be used to reverse the order of elements in an array. it is particualrly particularly useful to call this function after calling the ''Array.Sort()'' function to sort elements into reverse order:
<pre>