Function String Manipulations Class

StringEveryNthCharRepeated

"String Every Nth Character Repeated" Creates the string resulting from taking the character at position 1 (one) and at every Nth succeeding position (where N = vStep), then by repeating this process until the start position is equal to the vStep.

Signature (Visual Basic / VBA)

Public Function StringEveryNthCharRepeated( _
      ByVal vString As Variant _
    , Optional ByVal vStep As Variant _
    , Optional ByVal vTruncate As Variant _
    ) As Variant

Code Example

    StringEveryNthCharRepeated("123456789", 2, False) = "135792468"
    StringEveryNthCharRepeated("1234567890", 3, False) = "1470258369"
    StringEveryNthCharRepeated("123456789", 2, True)  = "13579" ' #3
    StringEveryNthCharRepeated("1234567890", 3, True)  = "14702583" ' #4

Parameters

Parameter Description
vString The string whose characters are to be rearranged. Function returns Null if vString is Null or cannot be fixed up to a String.
vStep The number of character positions to move after extracting each character. vStep defaults to 1 (one) if it is missing or Null or cannot be fixed up to a number. Function returns an empty string if the step is <= 0 (less than or equal to zero).
vTruncate Determines whether the last sub-string is truncated or included within the result. vTruncate defaults to False if it is missing or Null or cannot be fixed up to a number, as in examples #3 and #4.