Unlike most Visual Basic controls, the Internet Transfer control does not display a graphic image at runtime. At design time, you see it as a small box with an icon on it. This is similar in function to the MAPI controls I talked about in Chapter 8.
Like the other types of Visual Basic controls, the Internet Transfer control includes a number of properties that determine how it operates. Table 11.2 lists the most important Internet Transfer control properties.
Table 11.2: Selected Internet Transfer Control Properties
Property | Description |
AccessType | Specifies whether directly connected to the Internet or though a proxy server |
Document | Specifies the name of the document to be used with the Execute method |
hInternet | Specifies a handle to an Internet object created by the Wininet.DLL API |
Password | Specifies the password associated with a particular user name |
Protocol | Specifies the protocol used to talk to the remote server—usually FTP, HTTP, or HTTPS |
Proxy | Specifies the name of a proxy server and port number to be used |
RequestTimeout | Sets the number of seconds without activity before an error is returned |
RemoteHost | Specifies the name of the remote server |
RemotePort | Specifies the port number on the remote server—usually 21 for FTP and 80 for HTTP |
ResponseCode | Specifies the response code returned by the server |
ResponseInfo | Specifies text information associated with the response code |
StillExecuting | When set to True, means that the previous method is still executing |
URL | Specifies the name of a document on a remote server and the protocol needed to access it |
UserName | Specifies a valid user name on the remote system |
The most important property is the Protocol property. This determines if the control will use FTP or HTTP to transfer a file.
The next most important property is the URL property. This property holds a lot of information such as the Protocol to be used, the name of the RemoteServer, the RemotePort number, the UserName and Password, plus the name of the Document to be retrieved.
NOTE: Set the URL first: Setting the URL property will in turn set the Protocol, the RemoteHost, the RemotePort, the Password and the UserName, and the Document properties. Note that the reverse is also true. Setting any or all of these properties will update the URL property with the new information.
It is important to remember that transferring files across the Internet can take a lot of time. This means that your program will issue a request to the server through the Internet Transfer control, and then will need to wait until the request is completed. You can use the StillExecuting property to determine when the request has been completed. (You can also wait for State = 12 in the StateChanged event, as described shortly.)
Sometimes, it is important to see the response code that the server returned. This information is available in the ResponseCode property. Any text information that the server returned with the response code is available in the ResponseInfo property.
Finally, if you access the Internet through a proxy server, you can include that information in the AccessType and Proxy properties.