Spc Function

Used with the Print # statement to position output.

Syntax

Spc(n)

The required n argument is the number of spaces to insert before displaying or printing the next expression in a list.

Remarks

If n is less than the output line width, the next print position immediately follows the number of spaces printed. If n is greater than the output line width, Spc calculates the next print position using the formula:

currentWritePosition + (n Mod width)

For example, if the current print position is 24, the output line width is 80, and you specify Spc(90), the next print will start at position 34 (current print position + the remainder of 90/80). If the difference between the current print position and the output line width is less than n (or n Mod width), the Spc function skips to the beginning of the next line and generates spaces equal to n – (width – currentWritePosition).

Note. Make sure your tabular columns are wide enough to accommodate wide letters.

Example

In the example below the Spc function is used to position output in a file.

' The Spc function can be used with the Print # statement.
' Open file for output.
Open "TESTFILE" For Output As #1
Print #1, "10 space between this string"; Spc(10); "and this string."
Close #1    ' Close file.

See Also

Print # Statement, Width # Statement, Mod Operator, Space Function , Tab Function