行尾的分号有什么作用?
一行代码末尾加分号有什么作用?
我在我接管的一些代码中看到了这一点:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Print
语句 抑制通常的默认 CRLF:(我的强调)
我找不到
Printer.Print
(如果单击“方法”链接 这里),但我希望它能起到同样的作用。A
;
at the end of aPrint
statement suppresses the usual default CRLF:(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.Print
是基本的 BASIC 语句,其历史可以追溯到 20 世纪 60 年代中期该语言诞生的初期。打印用于在窗体、图片框、打印机和即时(调试)窗口上显示数据行;它还可用于将数据记录写入文件。在 VB 中,Print 是作为方法实现的。Print 方法的一般格式为:
其中 object 是指上述对象之一(Form、PictureBox、Debug window、Printer),而 expressionlist 是指要打印的一个或多个数字或字符串表达式的列表。< /em>
表达式列表中的项目可以用分号 (;) 或逗号 (,) 分隔。表达式列表中的分号或逗号决定下一个输出的开始位置:
Print
语句的表达式列表中由分号分隔的项目立即依次打印。在语句中,如果
strName
包含“HARRY”,则 Print 语句将生成以下输出:摘录:了解分号和打印方法
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:
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:
Items in the expression list of a
Print
statement that are separated by semicolons print immediately after one another. In the statementIf
strName
contained "HARRY", the Print statement would generate the following output:Excerpt : Understanding semicolons and print method