19.12.2012 Views

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

To access an initial Web page, you must specify an address called a Uniform Resource<br />

Locator (URL). You can do this by typing in a URL (or Locator) text box found toward the<br />

top of your browser or by typing in the dialog box that appears when selecting the Open comm<strong>and</strong><br />

from the File menu or clicking the Open button in the toolbar.<br />

■ A WEB BROWSER WALKTHROUGH<br />

1. Connect to the Internet either through your commercial service provider or by<br />

using your school’s network computers.<br />

2. Start up a Web browser such as Netscape, Mosaic, Lynx, or Internet Explorer.<br />

3. In the Location or URL text box toward the top of the browser, type in<br />

http://www.whitehouse.gov<br />

4. Press Enter.<br />

5. Click on one of the highlighted or underlined phrases (links) in the document.<br />

The page associated with this link will load. For instance if you click on “The<br />

President & Vice President:” you will see pictures of them <strong>and</strong> their wives along<br />

with information on how to send e-mail to them.<br />

6. Click on some other links to see what pages are brought up.<br />

7. When you are through exploring the White House page, try other URL addresses<br />

such as:<br />

Microsoft’s <strong>Visual</strong> <strong>Basic</strong> Page http://www.microsoft.com/vbasic<br />

Carl <strong>and</strong> Gary’s <strong>Visual</strong> <strong>Basic</strong> Page http://www.apexsc.com/vb<br />

Prentice-Hall’s Home Page http://www.prenhall.com<br />

The remainder of this section is devoted to using <strong>Visual</strong> <strong>Basic</strong> to create our own Web<br />

browser. The requirements for this task are as follows:<br />

1. A modem, or a direct internet connection.<br />

2. A Windows TCP/IP stack, usually referred to as a Winsock. (If you are using an<br />

Internet connection through your school, it almost certainly meets this requirement.<br />

If you are using a dialup connection from home, the Microsoft hookup to<br />

the network that comes with Windows will work.)<br />

3. Microsoft Internet Explorer 4.0 (or higher) must be installed.<br />

To Add the Web Browrser Control to Your <strong>Visual</strong> <strong>Basic</strong> Toolbox<br />

1. Invoke <strong>Visual</strong> <strong>Basic</strong>.<br />

2. Press Ctrl+T to invoke the Components dialog box.<br />

3. Click the check box next to Microsoft Internet Controls.<br />

4. Click the OK button.<br />

The Web Browser icon should now appear in your toolbox.<br />

EXAMPLE 1<br />

The following program creates a simplified Web browser. (Before running the program, be sure you are<br />

connected to the Internet as discussed above.) The primary task of the program, accessing the Web, is<br />

accomplished with the single statement<br />

WebBrowser1.Navigate(txtURL.Text)<br />

Accessing the Internet with <strong>Visual</strong> <strong>Basic</strong> 393<br />

The On Error Resume Next statement specifies that when a run-time error occurs, control goes to the<br />

statement immediately following the statement where the error occurred where execution continues. This

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!