Public Function ReDimPreserveVariantMatrix( _
ByRef rMatrix() As Variant _
, Optional ByVal vLBound1 As Variant _
, Optional ByVal vUBound1 As Variant _
, Optional ByVal vLBound2 As Variant _
, Optional ByVal vUBound2 As Variant _
) As Boolean
"Re-dimension Preserve Variant Matrix"
Redimensions a two-dimensional array of Variants.
Preserves all elements that existed both before and after the re-dimension.
Summary: This function works around a limitation in Visual Basic's ReDim Preserve statement. It allows you to redimension any or all bounds of a two-dimensional array while preserving the contents of the elements that existed both before and after. New elements are left Empty.
Example: Assuming
Dim avarNums() As Variant
ReDim avarNums(0 To 5, 0 To 10)
avarNums(1, 1) = .45
avarNums(2, 3) = .12
' ....
for example
' Same as ReDim Preserve avarNums(-5 To 10, 0 To 10)
' if Visual Basic would allow it.
ReDimPreserveVariantMatrix(avarNums(), -5, 10) = True
leaves
avarNums(1, 1) = .45
avarNums(2, 3) = .12
' Etc.
See also: ReDimPreserveVariantCube Function
ReDimPreserveVariantVector Function
BasicExtensions Class
ReDim Preserve Statement (Visual Basic)
rMatrix: Dynamic, two-dimensional array of Variant values that will be redimensioned. rMatrix must already be dimensioned before it is passed to this function or else an error will occur.
vLBound1: New lower bound for the first dimension. If vLBound1 is missing or Null or cannot be fixed-up to a number, it defaults to the current lower bound for the dimension (LBound(rMatrix, 1)).
vUBound1: New upper bound for the first dimension. If vUBound1 is missing or Null or cannot be fixed-up to a number, it defaults to the current upper bound for the dimension (UBound(rMatrix, 1)).
vLBound2: New lower bound for the second dimension. Defaults to LBound(rMatrix, 2) if missing or ....
vUBound2: New upper bound for the second dimension. Defaults to UBound(rMatrix, 2) if missing or ....
Return value: Function currently always returns True.
Return to ENTISOFT Home Page
Copyright © 1999-2005 Entisoft