From Xojo Documentation
|You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!|
Resizes the array to the specified index.
arrayName.ResizeTo(ParamArray index As Integer)
|arrayName||n/a||The name of any previously declared array.|
|index||Integer||The new upper bound for the array. Use -1 remove all the array elements. Resizing the array to less than -1 causes an OutofBounds exception.
In the case of multi-dimensional arrays, pass as many index parameters as there are dimensions in the array.
The ResizeTo method is used to increase or reduce the number of rows in the array specified. Arrays are zero-based (the first element is zero) so you resize the array using a number that is one less than the number of elements you actually want. The number of parameters passed is the number of dimensions of the array being resized.
When you resize an array to -1, all rows are removed. It is faster to resize an array in this manner than to loop through the array and individually remove each row. You can use the array AddRow or AddRowAt methods to add rows or you can resize it again to the exact size you need.
When you ResizeTo an array to increase its size, any existing values in the array are retained.
When you resize an array to decrease its size, existing values are retained if they are still within the new array bounds.
Arrays can have a maximum index value of 2,147,483,646.
This example reduces the aNames array to 11 elements.
This example adds 10 elements to the aNames array
This example reduces the aPeople array to 11 elements for the first dimension and 6 elements for the second dimension
When you resize an array with no bounds, its elements are removed. This is a fast way to clear out an array: