The #Region directive enables you to collapse and hide sections of code in Visual Basic .NET files. #Region lets you specify a block of code that you can expand or collapse when using the Outlining and Hiding Code feature of the Visual Studio .NET Code editor. The ability to hide code selectively makes your files more manageable and easier to read.
#Region directives support code block semantics such as #If...#End If. This means they cannot begin in one block and end in another; the start and end must be in the same block. #Region directives are not supported within functions.
Syntax
The syntax for #Region is as follows:
#Region "identifier string"
'code region
#End Region
The identifier string
requires the quotes and acts as the title of the region when it is collapsed. The region is collapsed by default.
To collapse and hide a section of code