Click here to Skip to main content
15,888,610 members
Articles / Programming Languages / VBScript

Download web content using internet transfer control

Rate me:
Please Sign up or sign in to vote.
1.29/5 (12 votes)
11 Jul 2012CPOL2 min read 224.7K   6.4K   23   22
An article that shows the usage of Internet Transfer Control

Sample Image - sshot.jpg

In this simple article, I would like to shed light on Internet Transfer Control which is shipped with the current version of VB (Version 6.0). The intended audience of this article is beginners who have just jumped into this vast field of internet development. We all know that internet is used for transferring data, so it’s pretty easy to figure out what the “Internet Transfer Control” does. With this control data can be transferred using either FTP or HTTP protocol. In this article, we will have a look at the working of the control with both HTTP and FTP protocols. I will walk you through the code step by step and will discuss each line of code.

The code accompanying this article is very simple and was written to demonstrate the working of ITC. You can continue to do research on your own once this article gets you started. The program in the code could retrieve data from HTTP and FTP Servers.

Creating the application

Start a new exe project and from the components menu (Press Ctrl + T) select Microsoft Internet Transfer Control 6.0 and Microsoft Rich Textbox Control 6.0.

1. Add the internet transfer control to your form.
2. Add the rich text box to the form. Change the name property to txtURL and the text property to www.microsoft.com or whatever you want the default download location to be.
3. Add a control array of two command buttons. Change the caption property of the button with index 0 to Go and of the other button to Quit.

Here is the code that is executed when the user clicks the Go button:

Private Sub Command1_Click(Index As Integer)

Select Case Index
Case 0:
If txtURL.Text <> "" Then
RichTextBox1.Text = Inet1.OpenURL(txtURL.Text, icString)
End If

Case 1:	
End
End Select
End Sub

As you can see from the code that we have used the openurl method of the inet control. OpenURL method has the following syntax:

Inet1.OpenURL (URL, DataType)

URL is the full URL that you want to open; it can be either HTTP or FTP protocol. Datatype is the type of data that you want to retrieve, it can be byte or string. The two values are icString (the default, value=0) and icByteArray (value=1).
The return value of the OpenURL method is the data returned by the URL. This method operates synchronously, which means that the program pauses until the data transfer is complete. The synchronous nature of OpenURL is important.

That’s it folks, this is all you need to retrieve text from the remote site. Save the project and run it. Enter the URL from where you want to download the html text in the text box (txtURL) and press Go.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Pakistan Pakistan
S.S. Ahmed is a senior software engineer and works for a web and software development firm. Ahmed is a Microsoft Office SharePoint Server MVP. Ahmed specializes in creating database driven dynamic web sites. He has been creating customized SharePoint solutions for the last five years. Ahmed has worked in Visual Basic, Visual C, Java, ASP, .NET, SharePoint, InfoPath, BizTalk, etc. Ahmed enjoys travelling and has been to many parts of the world. Ahmed distributes most of his work freely to many internet sites. Ahmed also participates in different newsgroups and tries to help people out with their problems. Ahmed can be reached at share.point@yahoo.com

PEACE

S.S. Ahmed
Web: www.walisystems.com
Blog:www.sharepointblogs.com/ssa

Comments and Discussions

 
GeneralMy vote of 1 Pin
Dave Kreskowiak5-Mar-10 7:18
mveDave Kreskowiak5-Mar-10 7:18 
GeneralVista Pin
pwesson15-Jul-09 0:42
pwesson15-Jul-09 0:42 
GeneralMy vote of 1 Pin
kemome11-Apr-09 23:07
kemome11-Apr-09 23:07 
GeneralI need the HTML for a download button on my thank you page for a PDF product purchase. Pin
Hans van Krieken30-Jul-08 7:13
Hans van Krieken30-Jul-08 7:13 
Generalupdating gold rate from internet into vb.net application Pin
ershad10-Mar-08 6:21
ershad10-Mar-08 6:21 
QuestionInternet transfer control Pin
davidnorfolk14-Jul-07 8:35
davidnorfolk14-Jul-07 8:35 
GeneralRe: This problem Pin
Sukasa7-Apr-07 12:10
Sukasa7-Apr-07 12:10 
QuestionConsole App with Variables? [modified] Pin
CADDEX-hm14-Jul-06 6:51
CADDEX-hm14-Jul-06 6:51 
QuestionRe: Console App with Variables? Pin
CADDEX-hm14-Jul-06 6:58
CADDEX-hm14-Jul-06 6:58 
Questionfor some sites getting 403 Access denied Pin
Dipee14-Nov-05 21:12
Dipee14-Nov-05 21:12 
GeneralProblem with the HTML code being truncated. Pin
flinti11-May-05 10:48
flinti11-May-05 10:48 
GeneralINET and Digital Certificates Pin
Anonymous19-Apr-04 8:44
Anonymous19-Apr-04 8:44 
GeneralFile transfer Pin
Anonymous24-Nov-03 12:49
Anonymous24-Nov-03 12:49 
GeneralRe: File transfer Pin
Anonymous23-Dec-03 9:50
Anonymous23-Dec-03 9:50 
GeneralReally Cool Pin
gtho930522-Feb-03 18:32
gtho930522-Feb-03 18:32 
GeneralRe: Really Cool Pin
S.S. Ahmed25-Feb-03 18:59
S.S. Ahmed25-Feb-03 18:59 
QuestionCan I use INET control in VC Pin
Anonymous10-Jul-02 22:00
Anonymous10-Jul-02 22:00 
GeneralObject Required (sorry, im new to vb...) Pin
26-Mar-02 5:35
suss26-Mar-02 5:35 
GeneralRe: Object Required (sorry, im new to vb...) Pin
S.S. Ahmed25-Feb-03 19:03
S.S. Ahmed25-Feb-03 19:03 
Generalhelp with login/pass web using php Pin
17-Mar-02 6:41
suss17-Mar-02 6:41 
QuestionVisual Basic !? Pin
5-Nov-01 23:31
suss5-Nov-01 23:31 
AnswerRe: Visual Basic !? Pin
17-Mar-02 6:34
suss17-Mar-02 6:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.