Name

Space Function

Class

Microsoft.VisualBasic.Strings

Syntax

Space(number)
number (required; Integer)

An expression evaluating to the number of spaces required

Return Value

A String containing number spaces

Description

Creates a string containing number spaces

Rules at a Glance

While number can be zero (in which case the function returns the empty string), runtime error 5, “Invalid procedure call or argument,” is generated if number is negative.

Programming Tips and Gotchas

The Space function is most useful for creating a string buffer, an area where an external function can write data to be returned to the calling program.

Get VB.NET Language in a Nutshell, Second Edition 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.