Freetutes.com

VB6 beginners tutorial - Learn VB6

Advanced VB6 tutorial - Learn Advanced VB6

VB .NET - Learn Visual Basic .NET

Systems Analysis - System analysis and Design tutorial for Software Engineering


You are here: Visual Basic > Advanced VB6 tutorial > Chapter 14

Reacting to the Download Completion With the AsyncReadComplete Event

The UserDocument's AsyncReadComplete event fires when the asynchronous download that you requested with the AsyncRead method 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 14.9.

LISTING 14.9
CODING THE ASYNCREADCOMPLETE EVENT PROCEDURE

Private Sub UserDocument_AsyncReadComplete _
(AsyncProp As AsyncProperty)
If AsyncProp.PropertyName = "PRETTYPIX" Then
Set PicPretty.Picture = AsyncProp.Value
End If
End Sub

In order to help you handle the data, the AsyncReadComplete event procedure passes a parameter, AsyncProp. AsyncProp 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 method).

  • 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.


  

<< Previous | Contents | Next >>

Home | About Us | Privacy Policy | Contact Us

Copyright © Freetutes.com | All Rights Reserved