Print Spaces Method
The Print Spaces method prints a number of spaces. It returns a string of spaces in the target of a Print statement. You can use it only in a Print statement. To determine the number of spaces to print, it uses different rules according to the following values:
The value in the number argument is less than the total line width. It prints the number spaces according to the value of the number argument.
The value in the number argument is greater than the total line width. It prints the number of spaces according to the modulus of the following calculation:
Value in the argument that the Print Spaces method receives divided by the length of the string to print.
The modulus in this context is the remainder of a calculation rounded to an integer.
X is less is than the value of the number argument or number Mod width, where x is the difference between the current print position and the output line width. It skips to the next line and prints the value of the number argument minus x spaces.
You can use the Set File Width statement to set the width of a print line. For more information, see Set File Width Method.
Format
Spc(number)
The following table describes the arguments that you can use with this method.
Argument | Description |
---|---|
number |
An integer or integer expression that specifies the number of spaces to print. |
Example
The following example prints five spaces and the following string to a file:
ABCD
This example divides 15 by 10 with a remainder of 5 to determine the five spaces:
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