<-- Previous || Up || Next -->

Offset Variant Matrix Function
Array Manipulations Class

Public Function OffsetVariantMatrix( _
      ByRef rTo() As Variant _
    , ByRef vFm() As Variant _
    , Optional ByVal vOffset1 As Variant _
    , Optional ByVal vOffset2 As Variant _
    ) As Boolean

Copy a two-dimensional Variant array to another Variant array AND change the bounds of the array.
The size of the new array will be the same but the bounds can be different.
The elements are preserved but they are shifted into new positions according to the offsets.

Summary:
            rTo                    vFm
        1    2    3            0    1    2
      +----+----+----+       +----+----+----+
    1 | 12 | 34 | WV | <-- 0 | 12 | 34 | WV |
      +----+----+----+       +----+----+----+
    2 | 21 | 43 | CA |     1 | 21 | 43 | CA |
      +----+----+----+       +----+----+----+
Example:
    Assuming
       Static avarIn(0 To 45, 0 To 12) As Variant
       avarIn(1, 1) = "Smith"
       Dim avarOut() As Variant
    for example
       OffsetVariantMatrix(avarOut(), avarIn(), 1, 1) = True
See also:
    OffsetVariantVector Function (for one-dimensional arrays)
    CopyVariantMatrix Function (array bounds stay the same)
    OverlayVariantMatrix Function
rTo: Destination array that will receive a copy of array vFm. This function will attempt to re-dimension rTo so that it has the same dimensions as (but different bounds than) vFm. It will ignore errors during that re-dimension so that rTo can be a Static array. If rTo is Static, it must be two-dimensional and have the appropriate upper and lower bounds.
vFm: The two-dimensional array of Variants that will be copied to rTo. vFm can be either Static or dynamic. If vFm is dynamic, it must be dimensioned before being passed to this function.
vOffset1: Offset for the first-dimension bounds and elements within the new array. vOffset1 defaults to 0 (zero) if it is missing or Null or cannot be fixed-up to a number.
vOffset2: Offset for the second-dimension bounds and elements within the new array. vOffset2 defaults to 0 (zero) if it is missing or Null or cannot be fixed-up to a number.
Note: Function makes a temporary copy of the source array so that rTo and vFm can be the same.
Return value: Function currently returns True in all cases.
v1.2 Change: Changed to allow rTo to be Static by making the function ignore errors that occur while re-dimensioning the destination array rTo.
v1.2 Change: Changed arguments vOffset1 and vOffset2 to be Optional. If either argument is missing, it defaults to 0. When both offsets are 0, this function performs the same operation as CopyCariantMatrix.

Return to ENTISOFT Home Page

Copyright © 1999-2005 Entisoft