O'Reilly logo

VB.NET Language in a Nutshell, Second Edition by Steven Roman PhD, Paul Lomax, Ron Petrusha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Spc Function

Class

Microsoft.VisualBasic.FileSystem

Syntax

Spc(n)
n (required; Integer)

The number of spaces required

Return Value

A String containing n spaces

Description

Inserts spaces between expressions in a Print or PrintLine procedure

Rules at a Glance

  • Spc can only be used with the Print or PrintLine procedure.

  • If the width of the device being printed to is greater than n, the print position is set to immediately after the number of spaces printed by the Spc function.

  • If the width of the device being printed to is less than n, the print position is set to the current position plus the result of the formula n Mod devicewidth.

  • If n is greater than the difference between the current print position and the width of the device, Spc inserts a line break and then inserts spaces in accordance with the following formula:

    n - (devicewidth - currentposition)
  • When using a proportional font, the Spc function uses the average width of all characters for that particular font to determine the width of the space character to print.

Programming Tips and Gotchas

  • When the number of fixed-width columns is important, you should use either the Space or the Tab function, since there is not necessarily a relationship between the spaces provided by the Spc function and fixed-width columns.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required