Home
Search
 
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
 
 
 
TitleMake an ActiveX control that asynchronously downloads images directly into a PictureBox
Keywordspicture, PictureBox, download
CategoriesGraphics, Controls, Internet
 
Use the AsyncRead method. When the AsyncReadComplete event indicates the download is complete, load the downloaded picture into the control's Picture property and raise an event so the main program knows the picture is ready.
 
Public Sub DownloadPicture(ByVal picture_url As String)
    On Error GoTo DownloadPictureError
    AsyncRead picture_url, vbAsyncTypePicture
    Exit Sub

DownloadPictureError:
    MsgBox "Error " & Err.Number & " starting download." & _
        vbCrLf & Err.Description
    Exit Sub
End Sub

Private Sub UserControl_AsyncReadComplete(AsyncProp As _
    AsyncProperty)
    On Error GoTo AsyncReadCompleteError
    Set UserControl.Picture = AsyncProp.Value
    RaiseEvent PictureReady
    Exit Sub

AsyncReadCompleteError:
    MsgBox "Error " & Err.Number & " reading result." & _
        vbCrLf & Err.Description
    Exit Sub
End Sub
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated