Public Function StringEveryNthCharacter( _ ByVal vString As Variant _ , Optional ByVal vStart As Variant _ , Optional ByVal vLength As Variant _ , Optional ByVal vStep As Variant _ , Optional ByVal vTruncate As Variant _ ) As Variant
StringEveryNthCharacter("123456789", 2, 4, 5, False) = "2345789" StringEveryNthCharacter("123456789", 2, 4, 5, True) = "2345"See also:
CharacterEveryNthCharacter Function StringEveryNthCharRepeated Function StringEveryNthCharacterSample SubroutinevString: The string whose sub-strings are to be sampled. 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 sub-string. 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 (zero).
vLength: The length of each sub-string that is to be extracted. vLength defaults to 1 (one) if it is missing or Null or cannot be fixed up to a number.
Function returns an empty string if length is <= 0 (less than or equal to zero).
vStart: The character position at which the extraction process is to begin. When vStart is missing or Null or non-numeric, it assumes a default value based upon the step direction.
vStart defaults to 1 (one) if the step (vStep) is positive.
vStart defaults to the position of the Nth from last (where N = vLength) character if the step (vStep) is negative.
vTruncate: Determines whether the last partial sub-string is included in the result. vTruncate defaults to False if it is missing or Null or cannot be fixed up to a number. With vTruncate False, the last partial sub-string will be truncated/removed unless it is of length vLength. With vTruncate True, the last partial sub-string is always included within the result, no matter what its length.
Future: possible problem with this function when the step is negative--should possibly copy from current position (lngCurPos) backwards, instead of lngCurPos forwards.
Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.