Siebel VB Language Reference > VB Language Reference >

Spc Function


This standard VB function prints a specified number of spaces.

Syntax

Spc(number)

Argument
Description

number

An integer or integer expression indicating the number of spaces to print

Returns

A string of spaces in the target of a Print statement.

Usage

The Spc function can be used only inside a Print statement.

When the Print statement is used, the Spc function uses the following rules for determining the number of spaces to output:

  • If number is less than the total line width, Spc outputs number spaces.
  • If number is greater than the total line width, Spc outputs number Mod width spaces.
  • If the difference between the current print position and the output line width (call this difference x) is less than number or number Mod width, then Spc skips to the next line and outputs number - x spaces.

    To set the width of a print line, use the Width statement.

Example

This example outputs five spaces and the string ABCD to a file. The five spaces are derived by taking 15 Mod 10, or the remainder of dividing 15 by 10.

Sub Button_Click
   Dim str1 as String
   Dim x as String * 10
   str1 = "ABCD"
   Open "C:\temp001" For Output As #1
   Width #1, 10
   Print #1, Spc(15); str1
   Close #1
   Open "C:\TEMP001" as #1 Len = 12
   Get #1, 1,x
   Close #1
   Kill "C:\temp001"
End Sub

Related Topics

Print Statement
Space Function
Tab Function
Width Statement

Siebel VB Language Reference Copyright © 2006, Oracle. All rights reserved.