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.

Monday, September 5, 2011

Select Tab Page Code.

In order to understand how to select Tab Pages by code in VB.Net, you must understand the difference between TAB CONTROL and TAB PAGE.

TAB CONTROL - a control that contains and organize different items that shares the same space in a form.

TAB PAGE - each page in a Tab Control is called a tab page, by default in VB.net there are two tab pages when you create a new Tab Control.

You can change page view by clicking the Tabs, but you can also create a code to change page views. Below is the sample code on how to change view through code.

Example Code:   TabControl1.SelectedTab = TabPage1