Used with
ReDim to preserve contents will resizing an array
Syntax
Description
Used with
ReDim so that when an array is resized, data is not reset but is preserved. This means when the array is enlarged that only new data is reset, while the old data remains the same.
In arrays with more than one dimension, only the first subscription can be redimensioned (arrays are stored in row-major order, so it's the first, not the last subscription).
Example
ReDim array(1 To 3) As Integer
Dim i As Integer
array(1) = 10
array(2) = 5
array(3) = 8
ReDim Preserve array(2 To 10)
For i = 2 To 10
Print "array("; i; ") = "; array(i)
Next
Differences from QB
- PRESERVE wasn't supported until PDS 7.1
See also