Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to download pictures from the web using Inet control

Status
Not open for further replies.

GPerk

Programmer
Jul 6, 2002
161
US
How can I use the Inet control to download pictures (usually png or bmp) from an URL and save the pics to disk files?

When I view these pics using a browser and move the cursor over the pic, a control bar appears. Then I can click on the disk icon and be prompted for the path and file name where the pic will be stored. If the pic is in png format, I can save it as a bmp file. I want to automate this process.

Is the Inet control the way to go?
Can I download the pic into a picturebox?Gene
 
This is the function i use to download files from the net. But it doesnot have a callback to get the return progress and all, but is effective..




Public Function GetInterNetFile(Location As String, fileName As String, DirToSaveAt As String) As Boolean
On Error GoTo errHand
Dim fromURL As String

fromURL = Location & fileName
Dim bData() As Byte
Dim intFile As Integer
intFile = FreeFile()
bData() = Form1.Inet1.OpenURL(fromURL , icByteArray)
Open DirToSaveAt & "\" & fileName For Binary Access Write As #intFile
Put #intFile, , bData()
Close #intFile
GetInterNetFile = True
Exit Function
errHand:
GetInterNetFile = False
If Err.Number = 35764 Then
MsgBox "Still Executing Last request", vbInformation
End If
If Err.Number = 35761 Then
MsgBox "Problem with the connection! Cannot resolve remote host!", vbInformation
Unload Me
Exit Function
End If
End Function




Regards,
Sunil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top