Function String Replacements Class

TranslateStringUsingCharacterPairs

Translate characters in vLine. Characters in vLine also appearing in odd-numbered positions in string vFromToChars are replaced with the following character from vFromToChars.

Signature (Visual Basic / VBA)

Public Function TranslateStringUsingCharacterPairs( _
      ByVal vLine As Variant _
    , ByVal vFromToChars As Variant _
    , Optional ByVal vCompare As Variant _
    ) As Variant

Code Example

    TranslateStringUsingCharacterPairs("This is a test.", "sXiYeZ") = "ThYX YX a tZst"

Parameters

Parameter Description
vLine The string in which characters are to be translated. Function returns Null if vLine is Null or cannot be fixed up to a String (Behavior #1).
vFromToChars The string containing pairs of characters that each describe how to translate one character into another. For example, a vFromToChars of "sXiY" tells this function to translate all "s" characters into "X" and to translate all "i" characters into "Y" Function returns Null if vFromToChars is Null or cannot be fixed up to a String (Behavior #2).
vCompare Specifies the type of comparison used to determine if characters match (Behavior #3). vCompare defaults to Binary comparisons if it is missing or Null or cannot be fixed up to a number (Behavior #4). Function uses the TranslateString function to actually perform the translation.

Notes & Version History

Details Like the TranslateString function, except that this one requires one string with pairs of find-and-replace characters.