STRING(number, character)

Returns a repeating character of a given length (Variant / String).

numberThe length of the returned string (Long)
characterThe character code specifying the character or string expression whose first character is used to build the return string (Variant)

* If "number" > 256, then the number used is "character" Mod 256.
* If "number" is Null, then Null is returned.
* If "character" is a number, then it is converted to a character.
* If "character" < 0, then a run-time error is generated.
* If "character" is Null, then Null is returned.
* You can use the STR function to return the text string of a number.
* You can use the STRREVERSE function to return the text string with the characters reversed.
* You can use the STRING$ function to return a String data type instead of a Variant data type.
* For the Microsoft documentation refer to

Debug.Print String(5,"a")     '= "aaaaa"  
Debug.Print String(2,"abcd") '= "aa"
Debug.Print String(3,"abcd") '= "aaa"
Debug.Print String(4,"b") '= "bbbb"
Debug.Print String(5,40) '= "((((("
Debug.Print String(5,80) '= "PPPPP"
Debug.Print String(5,"") '= run-time error
Debug.Print String(-5,"a") '= run-time error

© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited Top