|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
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 you need to do is run it!
For a video demonstration, see Video: Creating Your First Visual Basic Program.
To run your program
Connect your computer to the Internet.
On the Debug menu of the Visual Basic IDE, click Start Debugging.
This command runs your program.
A shortcut to run your program is to press F5.
In the text box, type http://www.microsoft.com and click the Go! button.
Thecontrol in your program navigates 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.
To close the program, on the Debug menu, click Stop Debugging.
You can also end the program by clicking the Close button on the top-right corner of the form.
In this lesson you ran your program to see if it worked. For most Visual Basic programs, you will repeat this process many times. Typically after adding some new code, you will run the program to see if the code does what you expected it to do—if it doesn't, you will need to fix it. This process is called debugging; it will be discussed in detail in a later lesson.
It may seem like magic that your program navigates 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, saving you time and effort. If you had to do it all yourself, it would take hundreds or even thousands of lines of code!
If your program does not run or display the Web page, there are a few things you can check:
Make sure you are connected to the Internet. Open Internet Explorer and try to navigate 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 (http://www.microsoft.com) correctly.
Go back and checkand make sure that you put the correct controls on the form.
Go back toand make sure that you typed the code correctly.
Congratulations! Your first Visual Basic program is complete. 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 more features of the Visual Basic programming language.