Function Character Arrays Class

KeepCharacters

Return a string containing all of the characters in vLine that also appear in vKeepChars. This is the opposite of the StripCharacters function.

Signature (Visual Basic / VBA)

Public Function KeepCharacters( _
      ByVal vLine As Variant _
    , ByVal vKeepChars As Variant _
    , Optional ByVal vCompare As Variant _
    ) As Variant

Code Example

    KeepCharacters("CBA123CBA", "ABCDEFGHI") = "CBACBA"

Parameters

Parameter Description
vLine String containing the characters which will be copied to the result string only if they also appear within string vKeepChars. Function returns Null if vLine is Null or cannot be fixed up to a String.
vKeepChars String containing the characters which will be copied to the result string each time they appear within string vLine. Function returns Null if vKeepChars is Null or cannot be fixed up to a String.
vCompare specifies the type of string comparison used to determine if characters match. vCompare defaults to Binary comparisons if it is missing or Null or cannot be fixed up to a number.

Notes & Version History

Note Similar to the KeepRangeOfCharacters function, except that one requires the range of ASCII values that will kept and it uses Binary comparisons.