Buscar..


Observaciones

Bloques de comentarios

Si necesita comentar o descomentar varias líneas a la vez, puede usar los botones de la barra de herramientas de edición del IDE:

Bloque de comentarios : agrega un solo apóstrofe al inicio de todas las líneas seleccionadas

Bloque de comentarios

Descomprimir bloque : elimina el primer apóstrofe del inicio de todas las líneas seleccionadas

Descomentar bloque

Comentarios multilínea Muchos otros idiomas admiten comentarios de bloque multilínea, pero VBA solo permite comentarios de una sola línea.

Apóstrofe Comentarios

Un comentario se marca con un apóstrofe ( ' ) y se ignora cuando se ejecuta el código. Los comentarios ayudan a explicar su código a futuros lectores, incluido usted mismo.

Como todas las líneas que comienzan con un comentario se ignoran, también se pueden usar para evitar que el código se ejecute (mientras se depura o refactoriza). Colocar un apóstrofe ' antes de que su código lo convierta en un comentario. (Esto se llama comentar la línea.)

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

REM comentarios

Sub RemComments()
  Rem Comments start with "Rem" (VBA will change any alternate casing to "Rem")
  Rem is an abbreviation of Remark, and similar to DOS syntax
  Rem Is a legacy approach to adding comments, and apostrophes should be preferred

  Rem Comments CANNOT appear after a statement, use the apostrophe syntax instead
  Rem Unless they are preceded by the instruction separator token
  Debug.Print "Hello World": Rem prints a welcome message
  Debug.Print "Hello World" 'Prints a welcome message

  'Rem cannot be immediately followed by the following characters "!,@,#,$,%,&"
  'Whereas the apostrophe syntax can be followed by any printable character.

End Sub

Rem Comments can appear inside or outside a procedure


Modified text is an extract of the original Stack Overflow Documentation
Licenciado bajo CC BY-SA 3.0
No afiliado a Stack Overflow