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

Offset Variant Vector Function
Array Manipulations Class

Public Function OffsetVariantVector( _
      ByRef rTo() As Variant _
    , ByRef vFm() As Variant _
    , Optional ByVal vOffset As Variant _
    ) As Boolean

Copy a one-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 offset.

Summary:
       rTo          vFm
      +----+       +----+
    1 | 12 | <-- 0 | 12 |
      +----+       +----+
    2 | CA |     1 | CA |
      +----+       +----+
Example:
    Assuming
       Static avarIn(0 To 45) As Variant
       avarIn(1) = "Smith"
       Dim avarOut() As Variant
    for example
       OffsetVariantVector(avarOut(), avarIn(), 1) = True
See also:
    OffsetVariantMatrix Function (for two-dimensional arrays)
    CopyVariantVector Function (array bounds stay the same)
    OverlayVariantVector 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 one-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.
vOffset: Offset for bounds and elements within the new array. vOffset 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 argument vOffset to be Optional. If the argument is missing, it will default to 0. When the offset is 0, this function performs the same operation as CopyCariantVector.

Return to ENTISOFT Home Page

Copyright © 1999-2005 Entisoft