The Internet Transfer Control

The Visual Basic Internet Transfer control implements both FTP and HTTP protocols for us. You might wonder why Microsoft didn't create two controls: an FTP control and an HTTP control. It turns out that there is no need for that: the Internet Transfer control figures out which protocol to use based on the URL we pass to it (such as ftp://ftp.microsoft.com or http://www.microsoft.com).

This is how we'll use the Internet Transfer control: first, we'll add it to a program using the Project menu's Components item by clicking the entry marked Microsoft Internet Transfer Control 5.0. After the control appears in the toolbox, we'll double-click it to create a new Internet Transfer control in our program (the default name of this control is Inet1). Then all we have to do is to use the OpenURL() or Execute() method to access the Internet. The OpenURL() method gets the data we are trying to fetch, and the Execute() method executes FTP or HTTP commands such as GET or PUT.

There is one more thing you should keep in mind before we start our FTP example: OpenURL() is a synchronous method, and Execute() is asynchronous. This means that the OpenURL() method waits until the data you are requesting is downloaded; the Execute() method returns at once, and the code that follows it in your program is executed while Execute() is working. This arrangement can save time in very long file transfers. We'll begin by creating an FTP program.

© 1997 by Steven Holzner. All rights reserved.