Signature (Visual Basic / VBA)
Public Function StringToVariantVector( _
ByRef rLines() As Variant _
, ByVal vFromLine As Variant _
, Optional ByVal vSeparator As Variant _
, Optional ByVal vCompare As Variant _
) As Boolean
Code Examples
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"
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"
Assuming
Dim avarColumns() As Variant
for example
StringToVariantVector(avarColumns(), Null, "|") = False
leaves
LBound(avarColumns) = 0
UBound(avarColumns) = 0
IsEmpty(avarColumns(0)) = True
Parameters
| Parameter | Description |
|---|---|
| vFromLine | String whose delimited parts will be placed into the array elements. |
| 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. |
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.)
Notes & Version History
| 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). |
| v1.5 Note | This function is very similar to the new Split function in Visual Basic 6.0. |