行尾的分号有什么作用?

发布于 2025-01-05 06:44:59 字数 168 浏览 0 评论 0原文

一行代码末尾加分号有什么作用?

我在我接管的一些代码中看到了这一点:

Printer.Print "Customer: " & strCustomerName & " (" & strCustomerCode & ")";

What is the effect of having a semicolon at the end of a line of code?

I've seen this in some code I've taken over:

Printer.Print "Customer: " & strCustomerName & " (" & strCustomerCode & ")";

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

毁梦 2025-01-12 06:44:59

Print 语句 抑制通常的默认 CRLF:

charpos - 指定下一个字符的插入点。 使用分号将插入点定位在紧接显示的最后一个字符之后。使用 Tab(n) 将插入点定位到绝对列号。使用不带参数的 Tab 将插入点定位在下一个打印区域的开头。 如果省略 charpos,则下一个字符将打印在下一行。

(我的强调)

我找不到 Printer.Print(如果单击“方法”链接 这里),但我希望它能起到同样的作用。

A ; at the end of a Print statement suppresses the usual default CRLF:

charpos - Specifies the insertion point for the next character. Use a semicolon to position the insertion point immediately after the last character displayed. Use Tab(n) to position the insertion point to an absolute column number. Use Tab with no argument to position the insertion point at the beginning of the next print zone. If charpos is omitted, the next character is printed on the next line.

(My emphasis)

I can't find a reference for Printer.Print (it's not listed if you click the "Methods" link here), but I expect it does the same thing.

撧情箌佬 2025-01-12 06:44:59

Print 是基本的 BASIC 语句,其历史可以追溯到 20 世纪 60 年代中期该语言诞生的初期。打印用于在窗体、图片框、打印机和即时(调试)窗口上显示数据行;它还可用于将数据记录写入文件。在 VB 中,Print 是作为方法实现的。

Print 方法的一般格式为:

[object.]Print [expressionlist]

其中 object 是指上述对象之一(Form、PictureBox、Debug window、Printer),而 expressionlist 是指要打印的一个或多个数字或字符串表达式的列表。< /em>

表达式列表中的项目可以用分号 (;) 或逗号 (,) 分隔。表达式列表中的分号或逗号决定下一个输出的开始位置:

; (semicolon) means print immediately after the last value.
, (comma) means print at the start of the next "print zone".

Print 语句的表达式列表中由分号分隔的项目立即依次打印。在语句中,

Print "Hello,"; strName; "How are you today?"

如果 strName 包含“HARRY”,则 Print 语句将生成以下输出:

Hello,HARRYHow are you today?

摘录:了解分号和打印方法

Print is a fundamental BASIC statement that dates back to the first days of the language in the mid-1960s. Print is used to display lines of data on a form, picture box, printer, and the immediate (Debug) window; it can also be used to write records of data to a file. In VB, Print is implemented as a method.

The general format for the Print method is:

[object.]Print [expressionlist]

where object refers to one of the objects mentioned above (Form, PictureBox, Debug window, Printer) and expressionlist refers to a list of one or more numeric or string expressions to print.

Items in the expression list may be separated with semicolons (;) or commas (,). A semicolon or comma in the expression list determines where the next output begins:

; (semicolon) means print immediately after the last value.
, (comma) means print at the start of the next "print zone".

Items in the expression list of a Print statement that are separated by semicolons print immediately after one another. In the statement

Print "Hello,"; strName; "How are you today?"

If strName contained "HARRY", the Print statement would generate the following output:

Hello,HARRYHow are you today?

Excerpt : Understanding semicolons and print method

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文