如何:向代码中添加注释 (Visual Basic)

更新:2007 年 11 月

此示例显示占用整个源代码行、行的一部分和多于一行的注释。

示例

' This entire line is a comment.
Dim DailyTotal As Decimal = 0   ' Sales total for today.
' This comment is so long that it requires more than one line, so 
' the comment character (') must be repeated on the second line.

此代码示例也可用作 IntelliSense 代码段。在代码段选择器中,它位于“Visual Basic 语言”中。有关更多信息,请参见如何:在代码中插入代码段 (Visual Basic)

编译代码

此示例需要:

  • System 命名空间的引用。

    说明:

    您不能使用行继续符 ( _) 来延长注释。您必须在每一注释行的开头重复注释字符 (')。

请参见

任务

如何:在代码中拆分和合并语句

概念

代码中的注释