SPACE

SPACE(number)

Returns the specified number of spaces (Variant / String).


numberThe number of spaces you want in the text string (Variant / Long).

REMARKS
* This function is useful for formatting output and clearing data in fixed-lengths strings.
* If "number" < 0, then a run-time error occurs.
* If "number" cannot be converted into a number, then a run-time error occurs.
* You can use the SPACE$ function to return a String data type instead of a Variant data type.
* The equivalent .NET function is Microsoft.VisualBasic.Strings.Space
* For the Microsoft documentation refer to learn.microsoft.com

Debug.Print Space(10)                 '= "          "  
Debug.Print Space(-1) ' runtime error
Debug.Print Space("text") ' runtime error

Dim sText As String
sText = " ' " & Space(10) & " ' "
Debug.Print sText '= " ' ' " (with 12 spaces)

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