String function

Category: String / Text

Summary

Repeating character string.

Syntax

String(number, character) The String function syntax has these named arguments:
Part
Description
numberRequired; Long. Length of the returned string. If number contains Null, Null is returned.
characterRequired; Variant. Character code specifying the character or string expression whose first character is used to build the return string. If character contains Null, Null is returned.

Example

Example
This example uses the String function to return repeating character strings of the length specified.
Dim MyString
MyString = String(5, "*") ' Returns "*****".
MyString = String(5, 42) ' Returns "*****".
MyString = String(10, "ABC") ' Returns "AAAAAAAAAA".

Microsoft Support Page

https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/string-function

Back to Functions