You must follow a naming convention for all controls you use in code view.
Textboxes must start with tbx, e.g. tbxCustomerName
Labels must start with lbl, e.g. lblProduct
Buttons must start with btn, e.g. btnSubmit
Radio Buttons start with rb, e.g. rbBlonde
Check Boxes start with ck, e.g. ckNoble
Exception: a label that you never refer to in code view does not need to be renamed.
You must follow these naming conventions for variables.
Decimals must start with dec, e.g. decProduct.
Strings must start with str, e.g. strErrorMessage
Boolean variables must start with boo, e.g. booSuccess.
Integers must start with int, e.g. intCounter.
When you double click on a button named, say, button1, and you get the subroutine for the click event for button1, the IDE sets up that subroutine right then, on the fly. The subroutine statement will look like this:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Note the name of the subroutine is Button1_Click and the subroutine also “handles” Button1.Click.
If we go back in design mode and change the name of the button to btnMultiply, the subroutine line will look like this:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMultiply.Click
Note the name of the subroutine is still Button1_Click but the subroutine now handles btnMultiply.Click.
All dim statements are at the beginning of your subroutine