The VBA Space function creates a String consisting of a specified number of spaces.
The syntax of the function is:
Where the Number argument is the number of spaces making up the returned String.
|' Example 2 - Create a String containing 0 spaces.|
Dim str2 As String
str2 = Space( 0 )
' The variable str2 is now equal to "" (an empty string).
In the above example:
If you supply a negative Number argument to the VBA Space function, you will get the error:
If the Number that is supplied to the Space function is a text string that cannot be converted into a numeric value, you will get the error: