Use properties instead of constant or magic numbers

A common programming mistake is to hard-code literals that corresponds to some property. That is particularly true with certain controls like tab controls & pages. The tab control exposes a Value property that indicates the current tab and the pages contains a PageIndex property that indicates its position in the tabs of the control.

Thus, it’s common to see code like this:

This means that if the tab control changes (e.g. new page inserted in middle or is rearranged), we will end up with code running incorrectly. To avoid this extra maintenance, we can do this instead:

This enables us to have code that will always work even if we later re-arrange tabs or insert new tabs in middle without breaking the functionality we want for other tabs. More importantly, if we delete a tab, this will cause a compile time error to remind us to clean up the Case that no longer applies for the deleted tab. That happens because we reference the Me.pagXXXX page control.