Click here to Skip to main content
Licence 
First Posted 4 Nov 2001
Views 183,940
Bookmarked 18 times

Download web content using internet transfer control

By | 4 Nov 2001 | Article
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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

S.S. Ahmed

Web Developer

Pakistan Pakistan

Member

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

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 1 PinmvpDave Kreskowiak7:18 5 Mar '10  
GeneralVista Pinmemberpwesson0:42 15 Jul '09  
GeneralMy vote of 1 Pinmemberkemome23:07 11 Apr '09  
GeneralI need the HTML for a download button on my thank you page for a PDF product purchase. PinmemberHans van Krieken7:13 30 Jul '08  
Generalupdating gold rate from internet into vb.net application Pinmemberershad6:21 10 Mar '08  
QuestionInternet transfer control Pinmemberdavidnorfolk8:35 14 Jul '07  
GeneralRe: This problem PinmemberSukasa12:10 7 Apr '07  
QuestionConsole App with Variables? [modified] PinmemberCADDEX-hm6:51 14 Jul '06  
QuestionRe: Console App with Variables? PinmemberCADDEX-hm6:58 14 Jul '06  
Questionfor some sites getting 403 Access denied PinmemberDipee21:12 14 Nov '05  
GeneralProblem with the HTML code being truncated. Pinmemberflinti10:48 11 May '05  
GeneralINET and Digital Certificates PinsussAnonymous8:44 19 Apr '04  
GeneralFile transfer PinsussAnonymous12:49 24 Nov '03  
GeneralRe: File transfer PinsussAnonymous9:50 23 Dec '03  
GeneralReally Cool Pinmembergtho930518:32 22 Feb '03  
GeneralRe: Really Cool PinmemberS.S. Ahmed18:59 25 Feb '03  
QuestionCan I use INET control in VC PinsussAnonymous22:00 10 Jul '02  
GeneralObject Required (sorry, im new to vb...) Pinmembermicmi5:35 26 Mar '02  
GeneralRe: Object Required (sorry, im new to vb...) PinmemberS.S. Ahmed19:03 25 Feb '03  
Generalhelp with login/pass web using php PinmemberAnonymous6:41 17 Mar '02  
hi, i would like to do something like that:
 
the website targeted use PHP to login with a username and a password.
 
and then, some menu is shown, (all using .php or .php3 extension for viewing pages.)
 
the fact is, if i do not log with my user/password within internet explorer, i can't even retrieve files i want using internet explorer.
 
but, even after logging in, and when i am able to download any file ending with .php3?someparam=somevalue&another=anothervalue etc...
when i use a offlinebrowser application to save all pages i want, the external application finally download a page which says i'm not logged on. although i can still download that page opening an internet explorer windows... (and setting the offline browser 'spider' to identify itself as IE doesn't solve the problem.)
 
so i have figured out that i need something like your utility, which will log in using a specified username/password, and then, will download all files linked from a single url. (and that need to work with either .php or .php3?x=1&pass=2 files...)
 


QuestionVisual Basic !? PinmemberAnonymous23:31 5 Nov '01  
AnswerRe: Visual Basic !? PinmemberAnonymous6:34 17 Mar '02  

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

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

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120529.1 | Last Updated 5 Nov 2001
Article Copyright 2001 by S.S. Ahmed
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid