Table of contents
TOC
折叠目录
展开目录

选项卡函数Tab Function

office 365 dev account|上次更新日期: 2018/3/13
|
2 参与人员

使用Print #语句或Print方法用于确定输出位置。语法选项卡[ (n) ] 可选_n_参数是在显示或打印列表中下一个表达式之前要移动的列数。如果省略, Tab会将插入点移到下一个打印区域的开始。这允许使用而不是在区域设置中的逗号,逗号用作小数点分隔符选项卡备注如果当前行上的当前打印位置大于_n_,选项卡将跳到_n_th 列的下一步的输出行上。如果_n_小于 1,选项卡上移动打印定位到第 1 列。如果_n_大于输出行的宽度,选项卡计算下一个打印位置使用下面的公式: nMod宽度,例如,如果_宽度_为 80,而您指定选项卡 ( 90 )下一个打印将开始第 10 列 (余数 90/80)。如果_n_小于当前打印位置,比打印在下一行上计算出的打印位置开始。如果计算出的打印位置大于当前打印位置,则打印在同一行上计算出的打印位置开始。输出行最左端的打印位置始终为 1。当使用Print #语句来打印到文件时,最右边的打印位置是输出文件中,您可以使用设置的当前宽度宽度 #语句。Used with the Print # statement or the Print method to position output. SyntaxTab [ (n) ] The optional nargument is the column number moved to before displaying or printing the nextexpression in a list. If omitted, Tab moves the insertion point to the beginning of the nextprint zone. This allows Tab to be used instead of a comma inlocales where the comma is used as a decimal separator. Remarks If the current print position on the current line is greater than n, Tab skips to the n th column on the next output line. If n is less than 1, Tab moves the print position to column 1. If n is greater than the output line width, Tab calculates the next print position using the formula: nModwidth For example, if width is 80 and you specify Tab( 90 ), the next print will start at column 10 (the remainder of 90/80). If n is less than the current print position, printing begins on the next line at the calculated print position. If the calculated print position is greater than the current print position, printing begins at the calculated print position on the same line. The leftmost print position on an output line is always 1. When you use the Print # statement to print to files, the rightmost print position is the current width of the output file, which you can set using the Width # statement.

请注意 请确保表格列的宽度足以容纳较宽的字母。Note Make sure your tabular columns are wide enough to accommodate wide letters.

Print方法使用Tab函数时,将打印面分为均匀、 固定宽度的列。每个列的宽度是选定字体磅值中所有字符宽度的平均值。但是,没有任何关联这些字符所占的固定宽度列数之间打印的字符数。例如,大写字母 W 占用多个固定宽度列,而小写字母 i 占用少于一个固定宽度的列。When you use the Tab function with the Print method, the print surface is divided into uniform, fixed-width columns. The width of each column is an average of the width of all characters in the point size for the chosen font. However, there is no correlation between the number of characters printed and the number of fixed-width columns those characters occupy. For example, the uppercase letter W occupies more than one fixed-width column and the lowercase letter i occupies less than one fixed-width column.

示例Example

本示例使用Tab函数确定在文件和即时窗口中的输出位置。This example uses the Tab function to position output in a file and in the Immediate window.

' The Tab function can be used with the Print # statement.
Open "TESTFILE" For Output As #1    ' Open file for output.
' The second word prints at column 20.
Print #1, "Hello"; Tab(20); "World."
' If the argument is omitted, cursor is moved to the next print zone.
Print #1, "Hello"; Tab; "World"
Close #1    ' Close file.

Tab函数还可以使用Print方法。下面的语句打印文本第 10 列开始。The Tab function can also be used with the Print method. The following statement prints text starting at column 10.

Debug.Print Tab(10); "10 columns from start."

© 2018 Microsoft