Step 5: Run and Test Your Program

Now that your program is complete, it is time to run and test it. For complex programs, testing can be a long and difficult process, which will be discussed in detail in a later lesson. Happily, for this program, all that you have to do is run it!

link to video For a video version of this topic, see Video How to: Creating Your First Visual Basic Program.

To run your program

  1. Connect your computer to the Internet.

  2. On the Debug menu of the Visual Basic IDE, click Start Debugging.

    This command runs your program.

    Tip

    A shortcut to run your program is to press F5.

  3. In the text box, type https://www.microsoft.com and click the Go! button.

    The WebBrowser control in your program goes to the Microsoft home page. From there, you can navigate through any related links. To visit another Web page, type the address in the text box and click the Go! Button.

  4. To close the program, on the Debug menu, click Stop Debugging.

    Tip

    You can also end the program by clicking the Close button on the top-right corner of the form.

Closer Look

In this lesson you ran your program to see whether it worked. For most Visual Basic programs, you will repeat this process many times. Typically after you add some new code, you will run the program to see whether the code does what you expected it to do. If it doesn't, you will have to fix it. This process is referred to as debugging; it will be discussed in detail in a later lesson.

You might be surprised that your program moves to a Web page and displays it, all as a result of you writing a single line of code. This is the beauty of Visual Basic—all the necessary code is built into the WebBrowser control. This saves you work. If you had to do it all yourself, it would take hundreds or even thousands of lines of code!

Troubleshooting

If your program does not run or display the Web page, there are some things that you can check:

  • Make sure that you are connected to the Internet. Open Internet Explorer and try to move to the Microsoft home page. If it works in Internet Explorer, it should also work in your program.

  • Make sure that you typed the address (https://www.microsoft.com) correctly.

  • Go back and check Step 2: Create a User Interface and make sure that you put the correct controls on the form.

  • Go back to Step 4: Add Visual Basic Code and make sure that you typed the code correctly.

Next Steps

Congratulations! Your first Visual Basic program is finished. You have demonstrated how powerful programs can be developed quickly and easily by using Visual Basic. In the following lessons, you will be introduced to some features of the IDE.

Next Lesson: Introduction to the Visual Basic Express IDE

See Also

Tasks

Step 1: Create a Project in Visual Basic

Step 2: Create a User Interface

Step 3: Customize Looks and Behavior

Step 4: Add Visual Basic Code

Other Resources

Creating Your First Visual Basic Program

What Went Wrong? Finding and Fixing Errors Through Debugging