October 27, 2016
Hot Topics:

Using the Internet Transfer Control: Part 1

  • November 19, 2002
  • By Sam Huggill
  • Send Email »
  • More Articles »

When downloading data, you will use the Inet controls OpenURL method. It takes two parameters, URL and DataType. Both are optional, so you can set them using the properties and omit them when you make the call. Unfortunately the Inet control does not provide a string data type, so we use the one closest to it, named icByteArray. But this means we have to work a bit with the returned data. We can use the UBound function to work with the bytearray data, and write it to a string value. Take a look:

Dim b() As Byte
Dim intCount As Integer
Dim strData As String

Inet1.Cancel ' Stops any current operations

b() = Inet1.OpenURL("http://www.vbsquare.com/ _
      index.html", icByteArray)

For intCount = 0 To UBound(b) - 1

  strData = strData & Chr(b(intCount))

Next intCount

And if you wanted to save the data to a file instead of a string variable, just use:

Open "myfile.txt" For Binary Access Write As #1

Put #1, , b()

Close #1

There we go. A nice simple web page downloader.

If you think you can do any better (which I am sure you can) then email me the files and I will post them. Please, give me some feedback on this HowTo. I am trying to get the balance right, am I doing it? Are you interested in more internet comms? Or do you want more database / client/server information? Did you think this HowTo was too basic or too advanced? Too long or too short? Tell me what you thought at sam@vbsquare.com Tell me what you are working on at the moment, and what you want to see in this newsletter: sam@vbsquare.com or use the online feedback form at http://www.vbsquare.com/feedback.htm

Page 4 of 4

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Thanks for your registration, follow us on our social networks to keep up-to-date
Rocket Fuel