Home
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
 
 
 
 
TitleDownload a picture from the Web and display it
Keywordsdownload, Web, picture, URL, Inet, Internet Transfer Control
CategoriesControls
 
Use the Internet Transfer Control's OpenURL method to fetch the picture into a byte array. Use Put to write the bytes into a temporary file. Then use LoadPicture to load the results.
 
' Download the picture and display it.
Private Sub cmdGo_Click()
Dim bytes() As Byte
Dim fnum As Integer

    ' Provide feedback.
    cmdGo.Enabled = False
    txtFile.Enabled = False
    txtURL.Enabled = False
    picResult.Picture = Nothing
    Screen.MousePointer = vbHourglass
    DoEvents

    ' Get the file.
    bytes() = inetDownload.OpenURL( _
        txtURL.Text, icByteArray)

    ' Save the file.
    fnum = FreeFile
    Open txtFile.Text For Binary Access Write As #fnum
    Put #fnum, , bytes()
    Close #fnum

    ' Display the file.
    picResult.Picture = LoadPicture(txtFile.Text)
    If ScaleHeight < picResult.Top + picResult.Height + 120 _
        Then
        Height = picResult.Top + picResult.Height + _
            120 + Height - ScaleHeight
    End If

    ' Reenable controls.
    cmdGo.Enabled = True
    txtFile.Enabled = True
    txtURL.Enabled = True
    Screen.MousePointer = vbDefault
    Beep
End Sub
 
 
Copyright © 1997-2001 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated