Function String Manipulations Class

SwapCharacters

Swaps every other character within a string, so "ABCD" becomes "BADC". Strings with an odd number of characters have their last character retained. as in example #2.

Signature (Visual Basic / VBA)

Public Function SwapCharacters( _
    ByVal vValue As Variant _
    ) As Variant

Code Example

    SwapCharacters("ABCDEF") = "BADCFE"
    SwapCharacters("ABCDE") = "BADCE" ' #2

Parameters

Parameter Description
vValue The string whose pairs of character are to be reversed. Function returns Null if vValue is Null or cannot be fixed up to a String. Swap adjacent bytes.