Public Function ReverseEveryNCharacters( _ ByVal vValue As Variant _ , ByVal vSize As Variant _ ) As Variant
ReverseEveryNCharacters("ABCDEFGHI", 3) = "CBAFEDIHG" ReverseEveryNCharacters("ABCDEFGHIJ", 2) = SwapCharacters("ABCDEFGHIJ") ' #2 ReverseEveryNCharacters("ABCD", 3) = "CBAD" ' #3 ReverseEveryNCharacters("ABCDE", 3) = "CBAED" ' #4 ReverseEveryNCharacters("ABCDEFGHI", 1) = "ABCDEFGHI" ' #5See also:
SwapCharacters Function ReverseString Function StrReverse Function (Visual Basic)vValue: The string containing the sub-strings that are to be reversed. Function returns Null if vValue is Null or cannot be fixed up to a String.
vSize: The number of characters within each sub-string. Each sub-string of this size is reversed. Function returns Null if vSize is Null or cannot be fixed up to a number.
Calling ReverseEveryNCharacters with a vSize greater than or equal to the length of vValue is like calling the ReverseString function.
Calling ReverseEveryNCharacters with a vSize of two is like calling the SwapCharacters function, as in example #2.
If the length of vValue is not a multiple of vSize, then the remaining characters at the end of vValue are still reversed, as in examples #3 and #4.
vValue is returned as a string but no characters are reversed if vSize is <= 1 (less than or equal to one), as in example #5.
Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.