VB .Net

Trouble Shooting

[Build Error of Main Sub] [Blue Underline in the Codes Window]

Build Error of Main Sub

  1. When you first run your program you may encounter an error message saying:



    This happens because you changed the form name from Form1 to something else (and that is the right thing to do.) as shown below.



    In this example, I changed the form name to frmSample. Be sure that you change the form name in the Solution Explorer window as well as the form Properties window as shown below.



    This could can be fix by following steps.
  2. After clicking Yes on this window
  3. Click on OK on the following window.


  4. Double-click on the item says 'Sub Main" was not found....


  5. Click on the name of the form that you changed to, and click on OK.


  6. Run the program again.

 

Blue Underline in the Codes Window

You may see a blue underline under a variable name as shown below. There are two possible scenarios

Undefined Variables

It indicates that the variable is not defined. In the example, I defined a variable as intMyNumber, but I did not define intYourNumber. That is an error since all variables must be defined before use.

Undefined Control

Another example is the undefined control name as shown below.

txtOutput has a blue underline because it has a different name on the GUI as shown below.

To fix it, either change the name in the Properties window, or in the codes window to match the name in the GUI and codes.