Hi, ReDim statement is basically used to change the size of one or more dimensions of an array which size has been already declared. ReDim also help you to free up memory by reducing the array size. Or you can also increase your memory size by increasing the size of array with the help of RdDim statament.
Syntax:
Code:
ReDim [ Preserve ] name(boundlist) [ , name(boundlist) [, ... ]]
The ReDim statement is created only for arrays. Note that if you declare a variable to be of type Array, the ReDim statement does not have sufficient type information to create the new array. This statement will help you only help you at procedure level. Declaration context for a variable cannot be a source file, namespace, interface, class, structure, module, or block.
Rules to be used to declare any ReDim statement:- You can specify only the Preserve modifier.
- Resizing of different arrays at one time is possible, just separate that with comma.
- Each entry in boundlist can specify the lower and upper bounds of that dimension.
- It is possible to use -1 to declare the upper bound of an array dimension. TBasic).
- The ReDim statement cannot change the data type of an array variable or of its elements.
- It cannot provide new initialization values for the array elements.
- The ReDim statement cannot change the rank of the array.
- If you use Preserve, you can resize only the last dimension of the array.
- You can use ReDim on a property that holds an array of values.
- ReDim releases the existing array and creates a new array with the same rank.
- If you do not specify Preserve, ReDim initializes the elements of the new array to the default value for their data type.
- If you specify the Preserve modifier, Visual Basic copies the elements from the existing array to the new array.
Bookmarks