Function Character Arrays Class

StripCharacters

Strip characters out of a string wherever they occur. This is similar to the KeepCharacters function, except that KeepCharacters requires the list of characters to be kept instead of the ones to be removed.

Signature (Visual Basic / VBA)

Public Function StripCharacters( _
      ByVal vLine As Variant _
    , ByVal vStripChars As Variant _
    , Optional ByVal vCompare As Variant _
    ) As Variant

Code Example

    StripCharacters("A1B2A1B2", "1234567890") = "ABAB"
    StripCharacters("123ABC123", "DCBA") = "123123"

Parameters

Parameter Description
vLine String containing the characters which should be copied to the result string as long as they do not also appear within string vStripChars. Function returns Null if vLine is Null or cannot be fixed up to a String.
vStripChars String containing the characters which should not be copied to the result string when they appear within string vLine. Function returns Null if vStripChars 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 StripRangeOfCharacters function, except that one requires the range of ASCII values that will stripped and it uses Binary comparisons.