This documentation is archived and is not being maintained.

Space Function

Returns a string consisting of the specified number of spaces.

Public Shared Function Space(ByVal Number As Integer) As String

Parameter

Number
Required. Integer expression. The number of spaces you want in the string.

Exceptions/Errors

Exception type Error number Condition
ArgumentException 5 Number < 0.

Remarks

The Space function is useful for formatting output and clearing data in fixed-length strings.

Example

This example uses the Space function to return a string consisting of a specified number of spaces.

Dim MyString As String
' Returns a string with 10 spaces.
MyString = Space(10)
' Inserts 10 spaces between two strings.
MyString = "Hello" & Space(10) & "World"

Requirements

Namespace: Microsoft.VisualBasic

Module: Strings

Assembly: Microsoft Visual Basic .NET Runtime (in Microsoft.VisualBasic.dll)

See Also

SPC Function | ArgumentException Class

Show: