Ny build-in function in VBScript to repeat a string N-times

repeatstringvbscript

There is a function in VBScript String(number,character) returns a string that contains a repeating character of a specified length. E.g.:

String(5, "A")     ' output: "AAAAA"

Is there any function to repeat a string? E.g.:

RepeatString(5, "Ab")     ' output "AbAbAbAbAb"

Best Answer

No, nothing built in. Instead:

n      = 5
str    = "Ab"
result = replace(space(n), " ", str)