event fires when the
asynchronous download that you requested with the AsyncRead
finishes. You must write code in the AsyncReadComplete
event procedure to
handle the data that has just been downloaded.
An event procedure for AsyncReadComplete might look like Listing
CODING THE ASYNCREADCOMPLETE EVENT PROCEDURE
Private Sub UserDocument_AsyncReadComplete
(AsyncProp As AsyncProperty)
If AsyncProp.PropertyName = "PRETTYPIX"
Set PicPretty.Picture = AsyncProp.Value
In order to help you handle the
data, the AsyncReadComplete
event procedure passes a parameter,
has a special data type, AsyncProperty. AsyncProperty is a structured
variable with three elements that you can examine in the event procedure code you write:
AsyncProp.AsyncType. This is a
long integer and describes the type of download that's just occurred. It should
match the value of the second argument that you originally passed to the
AsyncRead method (see the previous section on the AsyncRead
AsyncProp.PropertyName. This is
a String that should match the third argument that you originally passed to the
AsyncRead method (see the discussion of the AsyncRead
method in the previous section). You should check this element to make
sure that it does match the identifier of the download you're expecting: There
could be confusion otherwise if more than one download is pending.
AsyncProp.Value. This Variant element
will contain the actual data downloaded. If AsyncType is
Picture or ByteArray, the entire contents of the download
will be in this variable. If AsyncType is File, then
the contents of this variable will be the path to the file on the local system
where the downloaded data has been stored by Visual Basic.