Function Array Conversions Class

VariantMatrixRowToVector

Copies a Row from a two-dimensionsional Variant array into a one-dimensional array.

Signature (Visual Basic / VBA)

Public Function VariantMatrixRowToVector( _
      ByRef rTo() As Variant _
    , ByRef vFm() As Variant _
    , ByVal vRowNumber As Variant _
    ) As Boolean

Code Example

    Assuming
       Static avarTable(0 To 2, 0 To 2) As Variant
       ' Column--v  v--Row
       avarTable(1, 1) "James"
       avarTable(2, 1) "Johnson"
       avarTable(1, 2) "Sam"
       avarTable(2, 2) "Smith"
       Dim avarFirst() As Variant
    for example
       VariantMatrixRowToVector(avarFirst(), avarTable(), 2) = True
    leaves
       LBound(avarFirst) = 0
       UBound(avarFirst) = 2
       IsEmpty(avarFirst(0)) = True
       avarFirst(1) = "Sam"
       avarFirst(2) = "Smith"

Parameters

Parameter Description
rTo Dynamic, one-dimensional Variant array that will receive the values. rTo must be dynamic so that this function can re-dimension it appropriately. rTo need not be initialized (with ReDim) before being passed to this function. rTo will be re-dimensioned from LBound(vFm, 1) to UBound(vFm, 1).
vFm Two-dimensional array of Variants from which one of the rows will be copied. Within this array, dimension #1 represents the Column and dimension #2 represents the Row.
vRowNumber Number of the Row whose values will be copied.

Return Value

Function does nothing and returns False if vRowNumber is Null or cannot be fixed-up to a number. Function currently returns True in all other cases.