Pages

Monday, September 19, 2011

Regions In VB.Net

Region Directive (or simply Regions) in VB.Net is used if you have very long codes and you want to organize and make you codes easy to access and to manage.With Regions you can categorize your codes based on their common or similar functions.

Regions are collapsible, you can hide or collapse a Region. A collapsed region will show every codes inside the region, but a hidden one shows only the Region Name that you declared (Remember that only collapsed regions are search-able). But imagine if you have bunch of bunch of codes and it is not inside a region, you will have a hard time scrolling and scrolling.

Below is the syntax.

     #Region "Region Name"

        ... codes ...
        ... codes ...
        ... codes ...

        #End Region


A region starts with the code #Region followed by the "Region Name" or the identifier string then the  #End Region.

Note: Do not put #Region or #End Region inside a function or subroutine, because it will not work.

No comments:

Post a Comment