Welcome to Web Programming With Visual Basic. As you can probably tell by the title of the book, the topic here is the integration of Visual Basic and the World Wide Web.
To start off the book, we'll go into reasons to use the Web as an information source and why you should choose Visual Basic as a Web development tool.
Then we'll go over the structure of the book—where you can find specific information. From there, you're on your way to becoming a Web-savvy Visual Basic developer.
You may ask, "Besides all the hype, what good is the Web?"
The answer is simple: The Web allows for the distribution of information over a wide area, to a wide audience at a low cost (compared to a WAN). This network of networks enables users from across the world to access data on any computer whose administrator has deemed that the data should be made public using the Web.
This opens up a lot of possibilities for both providing and gathering information. Couple the Web with the other features of the Internet: e-mail, network news, file repositories, and it's easy to see all the potential applications of the Web.
Here are a few ideas to get your mind going: first, a Web-based order entry form. This gives a remote salesman using a Web browser on a notebook computer the ability to place orders minutes after a deal is made. Another potential application is to provide a Visual Basic search engine that scans Web-based databases of résumé's for keywords. Finally, a custom Web browser that you provide to your customers. The browser allows access only to your Web site and even provides the ability to personalize the information on your Web server to match the customer.
The applications are as wide open as the Web itself, and I'm sure as more people jump on the Web bandwagon, more and more applications will spring up.
An important question at the start of any software design project is the choice of a language or languages to use. When you think about designing applications that use Web-based information, the question still applies: "Why should I use Visual Basic?"
Visual Basic makes sense for the following reasons:
The merging of Visual Basic and the ability to tie into real-time, distributed information using the Internet produces an interesting and very powerful tool. In the constant flux of the Internet, Visual Basic becomes a very practical choice for Web application development thanks to Visual Basic's rapid application development aspect.
Visual Basic can be used to create both client-side and server-side Web applications. A Web browser such as Microsoft's Internet Explorer is one example of a client-side application. It is used to "surf" the Web—browsing the Web pages at a Web site and moving to other pages or to a completely different Web site by using the hyperlinks provided on most Web pages. Another example of a client-side application is an application that retrieves stock quotes from a quote provider's Web sites and provides the quotes to the user in some fashion. This application is not a Web browser but does access Web-based information.
Server-side applications run alongside a Web server, such as Microsoft's Internet Information Server. The server-side application is executed under the direction of the Web server, typically in response to a request made by a client-side application such as a Web browser. Server-side applications typically serve as gateways between a user's Web browser and information stored on the Web server that is not typically accessible using a Web browser. Such information can include database tables, information-providing machines attached to the server, and even OLE-enabled applications to which the server has access.
In the beginning, the Web was predominantly used by, maintained by, and programmed under the UNIX platform. The reasons for this are simple: first, Unix was designed from the ground up to allow computers to easily communicate with one another and, second, Unix has always been available for a wide variety of hardware platforms. Additionally, the TCP/IP protocol on which the Web is based was initially designed for the Unix operating system in mind.
For these reasons, integrating the Web with Visual Basic was very impractical if not outright impossible. Then recently, with the standardized Windows sockets (or Winsock for short) interface, things got a lot easier. The Winsocket interface is a layer that resides between the Windows operating system and the TCP/IP protocol. By making API calls to the Winsock interface, the Windows programmer can avoid the complexities of the TCP/IP protocol and instead concentrate on developing services and tools that run over TCP/IP networks.
Built atop the Winsock interface are a large group of tools that abstract the messy details of TCP/IP and the Internet protocols. With these tools, Web programming became a very practical solution to most distributed information programming tasks. As you'll see throughout this book, many custom controls and other tools exist that the Visual Basic programmer can use to further remove the application code from the complexities of the TCP/IP protocol.
What will the future hold? One thing that I can guarantee about the future is change. The Internet is still a very cutting-edge and young technology. Not only does this mean that this book will serve as a funny 'snapshot in time' five years from now, but it means that your work as an Internet programmer will be a "work in progress" for a long time to come. Unlike COBOL programming, Web programming will be a skill that requires frequent reading and training to keep up-to-date.
As with many technical books, it's easy to get blown away unless you come into them well prepared. Although the main topic of this book is the World Wide Web, we aren't assuming more than a user level knowledge of the Web.
We've targeted this book to Visual Basic programmers who are familiar with the Internet, but who are by no means, Internet experts. You don't need to know every function exposed in the Winsock.DLL, but you should have some experience with Netscape, Internet e-mail, and perhaps transferring files via ftp.
If you get stuck, don't worry, the very source of your frustration may be your salvation as well. A decent number of Web sites are dedicated to Visual Basic, and a listing of them is covered in Appendix D, "Bibliography and Cool Web Sites."
While all of this new technology seems great, there are a few things to watch out for.
First and foremost is that any time you retrieve information over the Internet, you are using someone else's equipment. Although you have their implicit permission to do so doesn't mean programs you write should repeatedly access another site without permission from the owner. Also be wary of any automated Web programs that you write (See Chapter 11, "A Brief Introduction to Web Spiders and Agents," for a complete description). The last thing you want to do is anger a system administrator by overwhelming his or here server with requests. As always, test on a server where you're the administrator, or on a server you have permission to test programs on before actually putting it into distribution.
The other warning is that even with the knowledge obtained from reading this book, your learning about Web programming is just beginning. The Web and Visual Basic are continually changing entities, which means that to stay current and up-to-date requires keeping up on the latest tools, gadgets, and specifications. While this may seem like an incredible hassle compared to learning something more stable, most of its excitement comes from being one of the first to explore this new technology.
In this book you'll start with the HTTP protocol. Unfortunately, the publisher couldn't attach two aspirin underneath the accompanying CD-ROM in the back of the book, but take it slow—it isn't too bad. The material is covered in Chapter 2, "HTTP: How to Speak on the Web," which can be read from beginning to end and can also serve as a reference guide to the HTTP protocol.
We then move into DDE and OLE control of the Netscape browser in Chapter 3, "Interfacing to the Web with DDE and OLE". Although the chapter covers Navigator exclusively, other browsers (Spry's Mosaic and Microsoft's Internet Explorer, for example) are also controllable using DDE and OLE. However, their implementations of DDE and OLE are not covered in this book.
Chapter 4, "Using Web Browser Custom Controls," introduces a few of the many custom controls available to interface Visual Basic with the World Wide Web.
Next is coverage of CGI applications. If you don't know what CGI is, turn to Chapter 6, "The Win/CGI Interface," which covers the interface between Windows and CGI applications. In Chapter 7, "Creating CGI Applications in Visual Basic," you'll put this knowledge to use writing actual Win/CGI applications for Windows or Windows NT based Web servers.
One of the previously mentioned reasons to choose Visual Basic for Internet development included database accessibility. This is covered in detail in Chapter 8, "Database Connectivity: The WebGuest Application." In this chapter you design a complete guest book application similar to ones seen on most Web sites. In addition to entering information, users of the WebGuest application can also list and search information entered by previous registrants.
Chapter 9, "Connecting to OLE Server: Using the Web as a Front-End to Schedule Plus," covers using OLE to link the Web and Visual Basic to other OLE enabled applications. The application example presented in this chapter allows a doctor's office to accept and schedule appointments using their Web site. As appointments are created by the doctor's patients, they are entered into the Schedule Plus database for use by any other machine with access to the Schedule Plus data.
Chapter 10 continues the coverage of server-side applications with "Using OLE-ISAPI with the Microsoft Internet Information Server."
Chapter 11 provides a brief introduction to the role of Web Spiders and Robots and serves as the start of the section of the book covering client-side applications.
The first chapter in this section is Chapter 12, "QuoteWatcher: An Interactive Web Agent." In this chapter you create an application that retrieves price quotes for specified stocks and mutual funds. The quotes are obtained from a Web server that typically provides quotes in response to user input on one of the server's HTML forms. The QuoteWatcher application bypasses the need to use a Web browser and fill in those forms, however, by sending the proper requests to the Web server.
In Chapter 13, "Building an E-Mail Signature Generator," you build an application that constructs an e-mail signature file based on random quotations obtained from one of the many random quotation generators available on the Web. This signature file can then be used by your e-mail application to attach the newly generated signature to your outgoing e-mail.
Chapter 14, "WebSearcher: A Simple Search Tool," brings the concept of popular Web-based search engines to a client-side application. A simple search tool is developed that allows you to specify a Web page to search and the keyword for which to search. The WebSearcher then searches the specified page and any page to which it links for the keyword, providing a list of any "hits" it finds.
Finally, Chapter 15, "LinkChecker: A Spider that Checks for Broken Links," shows how to check a specified Web page for hyperlinks to resources that aren't accessible. This is useful if you administer a Web site and want to ensure that any hyperlink you place on your Web pages is valid.
Note boxes highlight important or explanatory information that compliments the topic at hand.
These tips give you helpful suggestions and shortcuts to improve your Visual Basic programming.
If you're about to do something that could damage your system, these warnings guide you through so this won't happen.
http://www.anything.com
These URLs appear throughout the book, pointing you to more examples, information, or technical support out there on the Web.
This book also uses computer type to denote sections of code and other application design elements, such as property names, property values, etc. Italic computer type refers to a placeholder that should be filled with the actual number, variable, or value represented.
Now that you know why Visual Basic is a fantastic Web development tool, it's time to get started on your road to Web programming mastery.
I would suggest starting with Chapter 2. This chapter serves as the foundation for many other chapters in the book. Although it can also serve as a great reference, if you don't read it in its entirety you should at least skim it for the general content before proceeding.
From there, you can choose to continue, reading straight through, or you can narrow your reading to cover either client-side or server-side applications. If you choose the former, start with Chapters 4 and 5 then move to Chapter 11, "A Brief Introduction to Web Spiders and Agents," and move on from there. If you choose to cover server-side applications, start at Chapter 6, "The Win/CGI Interface," and work your way to Chapter 10.
And, if you develop some snazzy applications after reading this book, drop us a line. We'd love to hear how this book has helped you. Craig can be reached at craige@richmond.infi.net and Brad's address is haasch@execpc.com.