Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
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-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated