撇号评论

注释由撇号(')标记,并在代码执行时被忽略。评论有助于向未来的读者解释你的代码,包括你自己。

由于忽略了以注释开头的所有行,因此它们也可用于防止代码执行(在调试或重构时)。在代码之前放置撇号'将其转换为注释。 (这叫做评论出来。)

Sub InlineDocumentation()
  'Comments start with an "'"

  'They can be place before a line of code, which prevents the line from executing
  'Debug.Print "Hello World"

  'They can also be placed after a statement
  'The statement still executes, until the compiler arrives at the comment
  Debug.Print "Hello World"  'Prints a welcome message

'Comments can have 0 indention....
     '... or as much as needed

  '''' Comments can contain multiple apostrophes ''''

  'Comments can span lines (using line continuations) _
    but this can make for hard to read code

  'If you need to have mult-line comments, it is often easier to 
  'use an apostrophe on each line

  'The continued statement syntax (:) is treated as part of the comment, so 
  'it is not possible to place an executable statement after a comment
  'This won't run : Debug.Print "Hello World"
End Sub

'Comments can appear inside or outside a procedure