Space, Space$ Functions |
Named Arguments
No
Syntax
Space(number)
number
Use: Required
Data Type: Integer
An expression evaluating to the number of spaces required.
Return Value
A Variant of subtype String containing number spaces (in the case of Space) or a String containing number spaces (in the case of Space$).
Description
Creates a string containing number spaces.
Rules at a Glance
While number can be zero (in which case the function returns a null string), runtime error 5, "Invalid procedure call or argument," is generated if number is negative.
Programming Tips and Gotchas
You can use the Space function to both pad and clear data stored in fixed-length strings. For example, the following code fragment fills a fixed-length string with spaces:
Dim strFixed As String * 32 ... strFixed = Space(Len(strFixed))
See Also
- String Function
Get VB & VBA in a Nutshell: The Language now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.