Function String Searches Class

FirstNonMatchingPosition

Returns the position of the first non-matching characters in corresponding positions of the two strings.

Signature (Visual Basic / VBA)

Public Function FirstNonMatchingPosition( _
      ByVal vOne As Variant _
    , ByVal vTwo As Variant _
    , Optional ByVal vCompare As Variant _
    ) As Variant

Code Example

    FirstNonMatchingPosition("AAABBBCCC", "AAACCCDDD") = 4
    FirstNonMatchingPosition("AAABBBCCC", "AAABBBCCC") = 0
    FirstNonMatchingPosition("AAABBBCCC", "AAABBB") = 7

Parameters

Parameter Description
vOne One of the two strings from which characters in corresponding positions will be compared for a match. Function returns Null if vOne is Null or cannot be fixed up to a String.
vTwo One of the two strings from which characters in corresponding positions will be compared for a match. Function returns Null if vTwo is Null or cannot be fixed up to a String.
vCompare Specifies the type of comparison used to determine if corresponding characters match. vCompare defaults to Binary comparisons if it is missing or Null or cannot be fixed up to a number. Function returns 0 (zero) if all corresponding characters match and the strings have the same length. Function returns the length of the shorter string plus one if all corresponding characters match but the strings have different lengths.