【发布时间】:2010-11-07 07:00:22
【问题描述】:
如何在VB中注释多行代码/代码块?
【问题讨论】:
-
附带说明,您可以在 VB.Net 中执行 block cmets (Ctrl-K,Ctrl-C)。
如何在VB中注释多行代码/代码块?
【问题讨论】:
VB 在语言级别没有这样的结构。它有使用撇号字符的单行 cmets:
' hello world
' this is a comment
Rem this is also a comment
但是,Visual Studio 具有自动执行此任务的功能。选择您想要的行并按 Ctrl+K+C 进行注释,然后按 Ctrl+K+U 取消注释(通用开发设置快捷方式,查看“编辑->高级”菜单,同时选择一些代码以查看快捷方式)。
【讨论】:
这里完全滥用编译器指令...但是:
#If False Then
Comments
go
here
#End If
您不会获得正确代码着色的好处(使用默认配色方案时它不会显示为绿色),并且隐式行继续系统会自动缩进从第二行开始的段落中的行。但是编译器会忽略文本。
【讨论】:
other answers 解释了如何在 VB.NET 中自动注释/取消注释。为了完整起见,在 VB6 中使用这些工具栏按钮:。更多详情here.
【讨论】:
这是一种创建多行注释的简便方法,该注释也是可折叠的。
If <![CDATA[ Multiline comment about this and that
Comment about this
and that and so on
with lots of lines
]]> Is Nothing Then : End If
当你折叠它时它看起来像这样
If <![CDATA[ Multiline comment about this and that ... Is Nothing Then : End If
【讨论】:
在 VB 中注释代码的方式:
rem。
(注: rem 表示备注 --> rem 用于在程序源代码中包含解释性备注。)
#if false(在此处输入您的代码)#endif -- 这两条语句中的代码将被注释掉。【讨论】:
要注释掉一大段代码,请突出显示要注释掉的代码,然后按 ctrl+K,然后按 ctrl kbd>+C。要取消对已注释代码块的注释,请点击 ctrl+K,然后点击 ctrl+U。
【讨论】:
选择您需要注释的行并按下键CTRL+K+C。
如果您需要取消注释,请使用 CTRL+K+U
【讨论】:
选择您要评论的行。
在 Visual Studio 中按 CTRL+K+C。它将帮助您一次评论多行。
【讨论】:
在 vb++ 中,您可以使用以下命令对注释块进行注释:
CommentStart==>输入您的评论 在很多行
【讨论】:
在 VS2010 VB.NET 中,在类/函数/属性/声明上方键入 3 次 '
然后它会自动生成一个评论块:
''' <summary>
''' GRP Business partner ID
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
在 C# 中相同,但键入 3 次 /
/// <summary>
///
/// </summary>
【讨论】:
类 C 风格的块 cmets /* 我的评论 */ 在例如多行 VB.net 语句。它们目前不可用。 但是,代替写作
myVal = "bla bla bla" /* my comment */ _
+ " more of the same " _
+ " and still more "
你可以写:
myVal = "bla bla bla" + 'my comment
" more of the same " +
" and still more "
这将适用于更高版本的 VB.Net。
【讨论】:
【讨论】: