<-- Previous || Up || Next -->

Repeat String To Length Function
String Manipulations Class

Public Function RepeatStringToLength( _
      ByVal vLength As Variant _
    , ByVal vRepeat As Variant _
    ) As Variant

Like the built-in String$() function, except all of the characters in the string are repeated until string is of length vLength.

Example:
       RepeatStringToLength(5, "ABC") = "ABCAB"
    whereas
       String$(5, "ABC") = "AAAAA"
Example:
       RepeatStringToLength(5, 65) = "AAAAA"
    assuming
       Chr$(65) = "A"
       Asc("A") = 65
See also:
    RepeatString Function
    RepeatStringCharacters Function
    String$ Function (Visual Basic)
vLength: The (maximum) length of the result string. Function returns Null if vLength is Null or cannot be fixed up to a number.

vRepeat: The string or character which is to be replicated until the result is of length vLength. 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 fully and/or partially until the resulting string has the specified length.

If vRepeat is numeric, the string is constructed from the character with that ASCII value.

Function returns Null when vRepeat is neither string nor numeric.

Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.