Function String Searches Class

FirstMatchingCharacter

Returns the first character within string vLine that matches any of the characters within string vFindChars.

Signature (Visual Basic / VBA)

Public Function FirstMatchingCharacter( _
      ByVal vStartPos As Variant _
    , ByVal vLine As Variant _
    , ByVal vFindChars As Variant _
    , Optional ByVal vCompare As Variant _
    ) As Variant

Code Example

    FirstMatchingCharacter(1, "4455CBA", "12BC") = "C"
    FirstMatchingCharacter(1, "4455CBA", "FGHIJ") = ""

Parameters

Parameter Description
vStartPos The position of the character in string vLine where the search is to begin. vStartPos defaults to 1 (one) if it is Null or cannot be fixed up to a number.
vLine The string which is to be searched from left-to-right for characters that appear in string vFindChars. Function returns Null if vLine is Null or cannot be fixed up to a String.
vFindChars String containing characters that are to be searched for within string vLine. Function returns Null if vFindChars is Null or cannot be fixed up to a String.
vCompare Specifies the type of comparison used to find matching characters present in both strings. vCompare defaults to Binary comparisons if it is missing or Null or cannot be fixed up to a number. Function returns an empty string if none of the characters in string vFindChars appear within string vLine.

Notes & Version History

Details Like the InStrCharacters function except that it returns the character itself instead of the position of the match.