Function String Searches Class

CountCharacters

Count the number of occurrences of the characters in vFindChars within string vLine.

Signature (Visual Basic / VBA)

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

Code Example

    CountCharacters("This is a test.", "ti", vbBinaryCompare) = 4
    CountCharacters("This is a test.", "ti", vbTextCompare) = 5

Parameters

Parameter Description
vLine String whose characters that are also in vFindChars are to be counted. Function returns Null if vLine is Null or cannot be fixed up to a String.
vFindChars The characters which are to be counted each time they occur in 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. vCompare defaults to Binary comparisons if it is missing or Null or cannot be fixed up to a number.