Function String Manipulations Class

RepeatString

Like the Visual Basic String$() function, except all of the characters in the string are repeated instead of only the first character within the string.

Signature (Visual Basic / VBA)

Public Function RepeatString( _
      ByVal vRepetitions As Variant _
    , ByVal vRepeat As Variant _
    ) As Variant

Code Examples

       RepeatString(3, "ABC") = "ABCABCABC"
    whereas
       String$(3, "ABC") = "AAA"
       RepeatString(3, 65) = "AAA"
    assuming
       Chr$(65) = "A"
       Asc("A") = 65

Parameters

Parameter Description
vRepetitions The number of times that the string or character vRepeat is to be repeated. Function returns Null if vRepetitions is Null or cannot be fixed up to a number.
vRepeat The string or character which is to be replicated. Note: Special argument fix-up code. Function returns an empty string if vRepeat is an empty string. If vRepeat is a string, the entire string is repeated the specified number of times. If vRepeat is numeric, the string is constructed from the character with that ASCII value. Function returns Null if vRepeat is neither string nor numeric.

Notes & Version History

Details Similar to the RepeatStringCharacters function, except that RepeatStringCharacters repeats each of the characters within a string.