REDIM
Jump to navigation
Jump to search
Description
- Changes the size of an array. An array that has been DIMensioned to hold a certain number of elements can be REDIMensioned to change the number of elements that it can hold.
Syntax
- one-dimensional array
- redim array(size)
- two-dimensional array
- redim array(size1, size2)
Hints
- REDIM erases any previous contents of an array and sets all of the elements to zero (0), or to an empty string ("") if it is a string array. Any data stored in the array before the REDIM must be read back into the array (re-stored) if it is still to be used.
- REDIM is useful if the number of data items your program needs to save to an array changes from the initial DIM size.
- You cannot change a one-dimension array to a two-dimension array (or vice versa) with REDIM.
Example
' code snippet...
dim cust$(1) 'dimension the array
'
'
'
'when we know that there are 510 customers perform a REDIM
redim cust$(510)
'all the data was erased from the array
'now read in the customer records
Useful Procedures
' Place a useful function or sub using this keyword here