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

String To Variant Vector Function
Array Conversions Class

Public Function StringToVariantVector( _
      ByRef rLines() As Variant _
    , ByVal vFromLine As Variant _
    , Optional ByVal vSeparator As Variant _
    , Optional ByVal vCompare As Variant _
    ) As Boolean

Parse a delimited string into a one-dimensional array of Variants.
Parse a string representing one row of delimited text,
placing each column value into one array element.

Top20: This function is among our "top-twenty" most useful.
Example #1:
    Assuming
       Dim avarColumns() As Variant
    for example
       StringToVariantVector(avarColumns(), "Car|Train|Plane", "|") = True
    leaves
       LBound(avarColumns) = 0
       UBound(avarColumns) = 3
       IsEmpty(avarColumns(0)) = True
       avarColumns(1) = "Car"
       avarColumns(2) = "Train"
       avarColumns(3) = "Plane"
Example #2:
    Assuming
       Dim avarColumns() As Variant
    for example
       StringToVariantVector(avarColumns(), "Car|Train|Plane", "+") = True
    leaves
       LBound(avarColumns) = 0
       UBound(avarColumns) = 1
       IsEmpty(avarColumns(0)) = True
       avarColumns(1) = "Car|Train|Plane"
Example #3:
    Assuming
       Dim avarColumns() As Variant
    for example
       StringToVariantVector(avarColumns(), Null, "|") = False
    leaves
       LBound(avarColumns) = 0
       UBound(avarColumns) = 0
       IsEmpty(avarColumns(0)) = True
See also:
    Split Function (Visual Basic)
    StringToVariantMatrix Function
    VariantVectorToString Function (inverse)
    GetToken Function, et. al.
rTo: Dynamic, one-dimensional Variant array that will receive the parts of the string vFm. 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.
Note: The lower bound of is initialized to 0 (zero), but the first element used is always 1 (one).
vFromLine: String whose delimited parts will be placed into the array elements.
Return value: Function does "ReDim rTo(0 To 0)" and returns False if vFromLine is Null or cannot be fixed-up to a String. (Function currently returns True in all other cases.)
vSeparator: String that separates the individual parts of vFromLine. vSeparator defaults to Null if it is missing or cannot be fixed-up to a String. When vSeparator is Null, there is no separator, meaning that entire string will be treated as one part.
vCompare: Specifies the type of comparison used to find separator strings within the String vValue. vCompare defaults to Binary comparisons if it is missing or Null or cannot be fixed up to a number.
v1.5 Note: This function is very similar to the new Split function in Visual Basic 6.0.

Return to ENTISOFT Home Page

Copyright © 1999-2005 Entisoft