Signature (Visual Basic / VBA)
Public Function SearchSortedStringSegments( _
ByVal vValue As Variant _
, ByVal vFind As Variant _
, ByVal vCompare As Variant _
, ByVal vSegmentLength As Variant _
) As Variant
Code Example
' Segment #: 111111222222333333444444555555
' Position within Segment: 123456123456123456123456123456
SearchSortedStringSegments("Ariz Calif Nev Ore Wash ", "Calif", vbTextCompare, 6) = 2
SearchSortedStringSegments("AZCANVORWA", "NV", vbTextCompare, 2) = 3
SearchSortedStringSegments("AZCANVORWA", "AN", vbTextCompare, 2) = 0
Parameters
| Parameter | Description |
|---|---|
| vValue | String containing the sorted, equal-length segments which are to be searched for the string vFind. Function returns Null if vValue is Null or cannot be fixed up to a String. |
| vFind | String which is to be searched for within the sub-string segments of vValue. Function returns Null if vFind is Null or cannot be fixed up to a String. |
| vCompare | Specifies the type of comparison used to determine if strings match. vCompare defaults to Binary comparisons if it is missing or Null or cannot be fixed up to a number. |
| vSegmentLength | The length of each sub-string segment within string vValue. Function returns Null if vSegmentLength is Null or cannot be fixed up to a number. Function returns Null if the segment length is < 1 (less than one). Note: For a match to occur, the find string vFind must match the RTrim$() of the sub-string segment--trailing spaces are ignored. |
Notes & Version History
| Note | This function uses a binary search algorithm so the segments must be sorted using the vCompare sort order/collating sequence for the function to work properly. |