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

Search Sorted String Segments Function
String Lists Class

Public Function SearchSortedStringSegments( _
      ByVal vValue As Variant _
    , ByVal vFind As Variant _
    , ByVal vCompare As Variant _
    , ByVal vSegmentLength As Variant _
    ) As Variant

Searches for the string vFind within the sorted string segments contained in vValue.
Function returns the number of the matching segment, or 0 (zero) if no match is found.

Examples:
    ' 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
See also:
    SortStringSegments Function
    SearchStringSegments Function
    StringSegmentXOfLengthY Function
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.
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.

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.

Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.