Block commenting VB/VB.NET code

前端 未结 12 1027
死守一世寂寞
死守一世寂寞 2020-12-06 03:57

How to comment multiple lines of code/block of code in VB?

相关标签:
12条回答
  • 2020-12-06 04:20

    VB doesn't have such a construct at the language level. It has single line comments using apostrophe character:

    ' hello world
    ' this is a comment
    Rem this is also a comment
    

    However, Visual Studio has a functionality to automate this task. Select the lines you want and press Ctrl+K+C for commenting and Ctrl+K+U for uncommenting (General Development Settings shortcuts, look at the "Edit -> Advanced" menu while selecting some code to see the shortcuts).

    0 讨论(0)
  • 2020-12-06 04:21

    Block comments in C-like style /* my comment */ would be useful on e.g. multi-line VB.net statements. They are currently not available. However, in place of writing

    myVal = "bla bla bla" /* my comment */ _
          + " more of the same " _
          + " and still more "
    

    You could write:

    myVal = "bla bla bla" + 'my comment
            " more of the same " +
            " and still more "
    

    That will work on the later versions of VB.Net.

    0 讨论(0)
  • 2020-12-06 04:22

    In the vb++ you can comment the blocks of the comment with:

    CommentStart==>Type your comment and on many of the lines<==CommentEnd+/inc.

    0 讨论(0)
  • 2020-12-06 04:24

    Ways you can comment code in VB:

    1. by using CTRL+K+C
    2. adding ' (Apostrophes symbol) in front of your code which you want to make it as comment
    3. adding rem in front of your code which you want to make it as comment. (Note: rem means remarks --> rem is used to include explanatory remarks in the source code of a program.)
    4. just select the particular code and click on the option called "comment out the selected lines" in the toolbar.
    5. #if false (enter your code here) #endif -- the code inside these 2 statements will be commented.
    0 讨论(0)
  • 2020-12-06 04:24

    Select the lines that you want to comment.

    Press CTRL+K+C in Visual Studio. It will help you to comment multiple lines at once.

    0 讨论(0)
  • 2020-12-06 04:24

    in VS2010 VB.NET, type 3 times ' above a class/function/property/declaration

    then it will auto generate a comment block :

    ''' <summary>
    ''' GRP Business partner ID
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    

    same thing in C# but type 3 times /

    /// <summary>
    /// 
    /// </summary>
    
    0 讨论(0)
提交回复
热议问题