FileSystem.SPC(Int16) 方法
定义
与 Print 或 PrintLine 函数一起使用以定位输出。Used with the Print or PrintLine function to position output.
public:
static Microsoft::VisualBasic::SpcInfo SPC(short Count);
public static Microsoft.VisualBasic.SpcInfo SPC (short Count);
static member SPC : int16 -> Microsoft.VisualBasic.SpcInfo
Public Function SPC (Count As Short) As SpcInfo
参数
- Count
- Int16
必需。Required. 在显示或输出列表中下一个表达式之前要插入的空格数。The number of spaces to insert before displaying or printing the next expression in a list.
返回
与 Print 或 PrintLine 函数一起使用以定位输出。Used with the Print or PrintLine function to position output.
示例
此示例使用 SPC 函数将输出定位于文件和 输出 窗口中。This example uses the SPC function to position output in a file and in the Output window.
' The SPC function can be used with the Print function.
FileOpen(1, "TESTFILE", OpenMode.Output) ' Open file for output.
Print(1, "10 spaces between here", SPC(10), "and here.")
FileClose(1) ' Close file.
注解
如果 Count 小于输出行宽度,则下一个打印位置紧跟打印的空格数。If Count is less than the output line width, the next print position immediately follows the number of spaces printed. 如果 Count 大于输出行宽度,则 SPC 使用公式计算下一个打印位置:IfCount is greater than the output line width, SPC calculates the next print position using the formula:
currentprintposition (+ (Count``Mod``width) ) currentprintposition(+(Count``Mod``width))
例如,如果当前打印位置为24,则输出行宽度为80,并且您指定 SPC(90) ,下一次打印将从位置34开始 (当前打印位置 + 90/80) 的剩余部分。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). 如果当前打印位置与输出行宽度之间的差异小于 Count (或 Count Mod width) ,则 SPC 函数将跳到下一行的开头,并生成等于 Count - (width - currentprintposition) 的空格。If the difference between the current print position and the output line width is less than Count (or Count Mod width), the SPC function skips to the start of the next line and generates spaces equal to Count - (width - currentprintposition).
备注
请确保表格列宽度足以允许宽信。Make sure your tabular columns are wide enough to allow for wide letters.