Sunday, June 15, 2014

VB.Net Tip: Creating Regions

As your code gets longer and longer, it becomes more and more difficult to navigate. While you can select classes and their methods from the drop-down lists above the main editor, you can also group your code into logical regions. Specify regions with the #region keyword and a description at the beginning of your segment and a corresponding #endregion keyword at the end of your segment. 

Example:
#region My First Programming
    Sub Main()
            MsgBox("How To Create VB.net Region")
    End Sub
#endregion

The beauty of using regions is that you can collapse any region by clicking the plus sign next to the #regionkeyword. This collapses the code into a gray line that shows the region description. As a developer, you may already be aware of this feature because automatically generated code in VS.NET usually uses his feature,

Note: In VB.Net you specify the region description in double-quotes. Also regions are not allowed within methods. Instead, create regions around methods and classes.

Related Posts:

  • VB.Net Tip: Creating Regions As your code gets longer and longer, it becomes more and more difficult to navigate. While you can select classes and their methods from the drop-down lists above the main editor, you can also group your code into logica… Read More
  • VB.Net: Encrypt Password. If you are developing a password-protected web site or database, then are you sure about storing user password information securely? Realize that the data in your database is not safe. So you could encrypt the data that yo… Read More