Online Visual Basic
If this chapter were written even a month before Microsoft introduced Visual Basic's
version 5, this chapter would be about as long as the entire guide! Internet programming
is not simple. If you look through a guidestore, you will see shelf after shelf containing
thick programming guides that teach how to build Internet applications.
Visual Basic programmers have been writing Internet-based programs for a while,
but before version 5, Visual Basic programmers had to do a lot more work than they
now have to do. You'll see that adding Internet Web access requires only that you
follow the steps in a simple wizard.
The highlights of this hour include
- Why both intranet and Internet programming support are vital
- Where to find Internet programming tools in Visual Basic
- How to request Internet support from the VB Application Wizard
- What to expect from the wizard's Web browser
- Which ISP requirements a user needs before he can access the Internet with your
Follow the Wizard
to the Web!
As mentioned in the introduction, Visual Basic version 5 makes Internet access
extremely simple. Way back in Hour 2, "Analyzing Visual Basic Programs,"
you learned how to start the VB Application Wizard that created an application shell
for you. You now know enough of the Visual Basic language to create a shell and modify
the application with specific code so that the application does work that you need
New Term: An intranet is a localized
version of the Internet and sometimes used as a local area network's protocol system.
TIP: You can use Visual
Basic's Internet connections to build routines and applications that access both
the Internet and your own company's intranet. The intranet is becoming the interface
of choice by many companies whose employees access the Internet. After all, shouldn't
the computer down the hall from you be as simple to access as a computer around the
world? Instead of using a separate networking software solution, many companies prefer
to leverage their existing Internet tools. You'll be able to build simple intranet
applications with Visual Basic by the time you finish this lesson.
WARNING: You must
have Microsoft's Internet Explorer 3.0 or later installed on your system before you
can create Visual Basic applications with Internet access.
One of the wizard's dialog boxes gives you access to the Internet. Try it yourself
by following these steps:
- 1. Start a new project.
2. From the New Project dialog box (shown in Figure 24.1), double-click VB
Application Wizard to start the wizard.
3. Read the dialog boxes and click Next as you follow the wizard's application
design. Accept all the default values on each dialog box and pause when you come
to the dialog box labeled Internet Connectivity (see Figure 24.2).
24.1. Click here to start the wizard and
add Internet support.
24.2. This wizard dialog box requests
New Term: A Web browser is a program
that lets you display and interact with colorful Web pages on the Internet.
New Term: URL (for uniform resource
locator) is an Internet Web site address where you can point a Web browser. URLs
generally begin with the http:// (which stands for Hypertext Transfer Protocol).
URL addresses can also specify an FTP (File Transfer Protocol) document or even another
document that resides on your computer or on another networked disk.
- 4. Click the Yes option to request Internet support. In addition, enter
a default URL in the text box. If you don't change the default URL, the Web browser
will go to Microsoft's home page when the application's user displays the Web browser
the first time.
If your company has a home page, you might want to enter that home page's URL in
the text box.
5. When you complete the Internet dialog box, continue clicking Next until you
get to the final wizard dialog box. Click Finish to complete the wizard and watch
the wizard generate your application. So far, nothing looks different from the wizard
you used to create an application back in Hour 2.
Close the wizard's summary dialog boxes and run the application. Figure 24.3 shows
the resulting Internet-based application.
24.3. Where's the Internet?
Obviously, something is wrong because the application does not look anything like
the Internet. When you ran the wizard, you accepted a lot of dialog box default values.
The wizard did not generate only an Internet application, but an application that
happens to contain Internet access.
Select View | Web Browser. The application will load the Web broswer form and
send the application to the Internet through your ISP.
Your Users Need an
An ISP (or Internet service provider) is an Internet service that you and your
users use to connect to the Internet. You might even work for a company that contains
the hardware needed to be its own ISP. If your PC has Internet access, you'll have
no trouble using the application you create.
Therefore, when you distribute your application, if the application has Internet
access, you'll need to warn the users that they, too, must have an ISP to use the
application with the Internet. Again, if your users are workers within your own company
that already provides Internet access to PCs, you'll have no problems with distributing
Using the Browser
When you select View | Web Browser with your generated application, your application
will attempt to make an Internet connection through your ISP. Generally, this means
that you'll have to log on to the Internet by issuing your username and password.
For example, if you subscribe to the Internet using the Microsoft Network online
service, you'll see Figure 24.4's Sign In dialog box right after you select View
| Web Browser.
24.4. You must connect to your ISP.
Obviously, anyone who runs your application must also log in to his ISP, and his
ISP login dialog box will appear in place of Figure 24.4's Microsoft Network Sign
In dialog box if he uses a different ISP.
Once you (or your application's user) log in to the ISP, the application displays
the Web browser and the Web page you set as the default, as shown in Figure 24.5.
The Web broswer includes the standard browsing tools that you are used to if you've
ever used a browser. You can perform all the following tasks from your application's
- You (or your application's user) can click on the Web page's hotspots to jump
to related Web pages.
- You can enter a new URL in the Address text box to see a different site.
- You can browser backward through the pages you've seen by clicking the toolbar's
- Once you back up, you can return to a Web page by clicking the toolbar's Forward
24.5. Your application now contains a
- If a Web page takes a long time to load its graphics, you can click the toolbar's
Stop button to freeze the page at its current loaded state. (Usually the text will
load long before all the graphics load and you may not need to view the rest of the
- You can refresh a Web page that you've stopped from loading or refresh to see
new information by clicking the toolbar's Refresh button.
- The toolbar's Home button takes you to the home page set up for your ISP (not
the URL you entered in the wizard's text box). You can select View | Options | Navigation
to set a different home page.
- Click the toolbar's Search button to locate other sites on the Internet. The
search site used will be the one defined for your ISP or one that you enter in the
View | Options | Navigation dialog box.
All this is possible and you never coded one programming statement to gain the
New Term: Java is a Web-based programming
language similar to C++. Java adds interactivity to a Web page.
NOTE: The browser
the wizard generated is Java enabled because it is based on Internet Explorer, which
is Java enabled. Your application will not get all the functionality of the full-functioned
Internet Explorer, but you will get most of the vital features such as Java and Web
TIP: Click the browser's
drop-down Address text box, shown in Figure 24.6, to go back to any specific Web
page you've visited during your browsing session.
24.6. You can review the sites you've
New Term: VBScript is a Web page scripting
language that you can use to activate Web pages and add intelligence to Web page
design and interaction with the user.
By the way, now that you've mastered Visual Basic, you know almost everything
there is to know about VBScript. Therefore, you'll be able to work as a Web page
programmer with just a little extra training in VBScript and HTML coding. For a great
text that explains how to use VBScript, get a copy of either Teach Yourself VBScript
in 21 Days or Laura Lemay's Web Workshop: ActiveX and VBScript (both by Sams.net
When you finish browsing the Web, you can close the Browser window and continue
with your application. Obviously, the wizard's application is still just a shell.
Nevertheless, the most functional part of the application is the Web browser, and
you can see how simple Visual Basic makes it to drop a browser into an application.
WARNING: Did you
notice how many new tools the wizard added to your Toolbox window to support the
Web browser? Close the application and look at the toolbox. You'll see additional
tools, labeled in Figure 24.7, that help the application do its tasks. Although the
Web browser is simple, the wizard did put its parts together. Although Visual Basic
supplies a Web Browser tool (see Figure 24.7), the tool requires other support tools
to have an object such as the drop-down Address list box.
24.7. The Web Browser tool requires
several controls to do its job.
TIP: To help your application's
users, you'll need to add more features to the Web browsing portion of your application.
For example, the application does not have a logoff feature. Perhaps you could add
a menu to the browser and include common options found in most browsing menus.
the Other Tools
When you select Project | Components and look through the list of tools you can
add to the Toolbox window, you'll find several Internet-related tools. For example,
all the controls that begin with the words Internet Explorer are Internet Explorer-like
controls you can add to an application. Table 24.1 describes these tools briefly.
FTP stands for File Transfer Protocol and refers to one computer's capability
to log on to the Internet and exchange files with another user's computer.
WinSock is the Windows interface to an Internet program.
You'll also find several FTP and WinSock controls that help you encapsulate advanced
Internet applications into packages you can use as a standalone Web browser or, more
commonly, as a Web browser you can make available in the middle of your application
for your application's users to use when needed. These extra controls are fairly
advanced, so read the extensive online documentation that Visual Basic provides for
Web applications in the guides Online reference sets.
In this hour you have quickly learned how to achieve Internet and intranet connectivity
from within the Visual Basic applications you write. If your application needs a
Web browser, the VB Application Wizard will take care of the details. If you need
more, you can add additional functionality to your application.
This hour's lesson completes this 24-hour tutorial. You should take a few days'
rest before returning to the keyboard to write the next killer application that outsells
Microsoft Office. Good luck with Visual Basic and with your programming future!
The quiz questions and exercises are provided for your further understanding.
See Appendix C, "Answers," for answers.
Use File | Print to print all the Web browser form's code. You'll see that the
wizard generated a lot of code and that some of the code is fairly tricky. By studying
the code, you'll see that these Internet controls can be difficult to program and
that the wizard takes a lot of that difficult task off your shoulders.