Function String Replacements Class

TranslateStringUsingTable

Translate characters in vLine. Like the TranslateString function except that this function requires a string containing the translation for every character between Chr$(0) and Chr$(255).

Signature (Visual Basic / VBA)

Public Function TranslateStringUsingTable( _
      ByVal vLine As Variant _
    , ByVal vTable As Variant _
    ) As Variant

Code Example

    Assuming
       Dim TransTable As String
       TransTable = Space$(64) + "acbdefghijklmnopqrstuvwxyz"
    for example
       TranslateStringUsingTable("ABCDEFabcdef", TransTable) = "abcdefabcdef"

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).
vTable The string containing the replacement/translation for each character. Each character within vTable is the replacement for the character whose ASCII value is its position within vTable - 1. For example, the first character within vTable is the translation for the character with ASCII value 0 (Chr$(0)), the second character within vTable is the translation for the character with ASCII value 1 (Chr$(2)), etc. Function returns Null if vTable is Null or cannot be fixed up to a String (Behavior #2). If the string vTable does not contain a translation for a character, then the character will remain un-translated (Behavior #3).

Notes & Version History

Note Function performs Binary comparisons (to determine if characters match) by virtue of the algorithm used (Behavior #4).