Creating Your First Windows 8 Application

  • 12/15/2012

Running Visual Basic Applications

To run a Visual Basic program from the development environment, you can do any of the following:

  • Click Start Debugging on the Debug menu.

  • Click the Start Debugging (Local Machine) button on the Standard toolbar.

  • Press F5.

Try running the My Web List program now. If Visual Studio has difficulty compiling your program or displays an error message, you might have made a typing mistake or two in your program code. Try to fix it by comparing the printed version in this book with the one you typed, or load Web List from this book’s sample files and run it.

Run the My Web List program

  1. Click the Start Debugging button on the Standard toolbar (the green arrow button with the words “Local Machine” next to it).

    The My Web List program will compile and run in the IDE. After a few seconds, the user interface appears, just as you designed it. The Microsoft MSN web site (http://www.msn.com) appears in the first text box as a sample web site you can browse to.

  2. Click the Visit Web Site button.

    The program uses the Navigate method of the WebView1 object to access the site. The web site appears in the web view object, and the web site URL appears in the second text box on the page. Your screen will look like this:

  3. Enter a new URL in the first text box, such as http://www.plu.edu, and then click Visit Web Site. (This is the university where I teach, but you can substitute your own favorite web address.)

  4. Visual Basic immediately adds the web site to the list of visited sites and loads the webpage into the web browser. Keep in mind that the content in the web browser is live—you can click around within the webpages and move from link to link as you would on a normal webpage. To see webpage content that is not currently visible, simply press the Down Arrow key or rotate the mouse wheel.

  5. Enter a third URL in the text box, such as http://msdn.microsoft.com, and then click Visit Web Site.

  6. Enter a fourth URL in the text box, such as http://www.microsoftpress.oreilly.com, and then click Visit Web Site.

    Your screen will look like this:

    Now that you’ve entered four or five web sites, you can begin to see the value of the web site address list that is slowly accumulating in the second text box. Visual Basic offers you the power to track all types of information, including a list of the web sites that you have visited. If you would like to save the list for future use, simply select the contents of the text box with your mouse, press Ctrl+C to copy the list to the Clipboard, open an application such as Notepad or Microsoft Word, and then press Ctrl+V to paste the list into the open document.

When you’re finished experimenting with the Web List program, close the application. You’ve just tested your first Windows application!

Sample Projects on Disk

If you didn’t build the My Web List project from scratch (or if you did build the project and want to compare what you created to what I built as I wrote the chapter), take a moment to open and run the completed Web List project now, which is located in the My Documents\Start Here! Programming in Visual Basic\Chapter 02 folder on your hard disk (the default location for the practice files for this chapter). If you need a refresher course on opening projects, see the detailed instructions in Chapter 1. If you are asked if you want to save changes to the My Web List project, be sure to click Save.

After you have compared the My Web List project to the Web List solution files on disk, reopen My Web List and prepare to compile it as an executable file. If you didn’t create My Web List, use the book’s solution file to complete the exercise.