撇號評論

註釋由撇號(')標記,並在程式碼執行時被忽略。評論有助於向未來的讀者解釋你的程式碼,包括你自己。

由於忽略了以註釋開頭的所有行,因此它們也可用於防止程式碼執行(在除錯或重構時)。在程式碼之前放置撇號'將其轉換為註釋。 (這叫做評論出來。)

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