Function Array Manipulations Class

ReverseVariantVector

Reverses the elements of a one-dimensional Variant array. The first element becomes the last, the last becomes the first, etc. The elements are reversed in place.

Signature (Visual Basic / VBA)

Public Function ReverseVariantVector( _
      ByRef rVector() As Variant _
    , Optional ByVal vMinElem As Variant _
    , Optional ByVal vMaxElem As Variant _
    ) As Boolean

Code Examples

    Assuming
       Static avarKeys(0 To 2) As Variant
       avarIn(0) = 12
       avarIn(1) = "CA"
       avarIn(2) = "TX"
    for example
       ReverseVariantVector(avarKeys()) = True
         rVector
    +----+     +----+
    | 12 | <-- | TX |
    +----+     +----+
    | CA |     | CA |
    +----+     +----+
    | TX |     | 12 |
    +----+     +----+

Parameters

Parameter Description
rVector One-dimensional array of Variant values whose elements' positions will be reversed. rVector must already be dimensioned before it is passed to this function or else an error will occur.
vMinElem Lower bound for the range of elements that will be reversed. If vMinElem is missing or Null or cannot be fixed-up to a number, it defaults to the current lower bound for the dimension (LBound(rVector)).
vMaxElem Upper bound for the range of elements that will be reversed. If vMaxElem is missing or Null or cannot be fixed-up to a number, it defaults to the current upper bound for the dimension (UBound(rVector)).

Return Value

Function currently returns True in all cases.

Notes & Version History

v1.2 Change Changed vMinElem to default to LBound(rVector) instead of 1 (one).
v1.3 BugFix This Function has been fixed to support the arrays containing elements of Object and DataObject type Values.