STRING |
STRING(number, character) |
Returns a repeating character of a given length (Variant / String). |
number | The length of the returned string (Long) |
character | The character code specifying the character or string expression whose first character is used to build the return string (Variant) |
REMARKS |
* If "number" < 0, then a run-time error occurs. * 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" > 256, then "character" Mod 256 is used. * 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 learn.microsoft.com |
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(300,80) '= "PPPPP"
Debug.Print String(5,"") '= run-time error
Debug.Print String(-5,"a") '= run-time error
Dim sValue As String
svalue = String(5, (256 + 56))
Debug.Print svalue '= "88888"
svalue = String(5, (256 + 56) Mod 256)
Debug.Print svalue '= "88888"
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited Top