WebQuery Events

DataAvailable

(ByVal channel As Integer, ByVal pageTitle As String)

This event is fired as soon as the page is loaded. It provides the developer with the title of the page that is loaded.

Enter

(ByVal channel As Integer)

This event is fired when entering the control from the main entry and before starting the http request. You can overwrite the control properties before the fetch process starts.

EnterCheckBack

(ByVal channel As Integer, ByVal howmany As Integer)

This event is fired when entering from the CheckBack entry. The argument howmany is the number of times checked back since the page started loading.

EnterNext

(ByVal channel As Integer, ByVal currentIndex As Integer)

This event is fired when entering from the Next Entry. The argument currentIndex is the number of times entered from this entry since loading the current page. If you do not use the property GetNextMatch, this argument should give you a correct zero-based index of the current match.

Exit

(ByVal channel As Integer, Node As Integer)

The exit event with the exit Node number (0 to 5).

ValidateNode

(ByVal channel As Integer, ByVal nodeText As String, invalidateNode As Integer)

This event is fired when an element is found to meet the criteria set by the control properties. The VB developer can rule out nodes that meet the control criteria but for other reasons are not desired results.

The argument nodeText is the TextResult intended to return to the application. That is, this is the InnerText of the returned node, not the searched element. This helps the VB developer apply extra filtering on the returned text.

The argument invalidateNode is an output the VB developer should set it to 1 to refuse the found node. For example:

For example, consider the following table:

Name

Phone

Smith, J.

(555)123-4545

Smith, M.

Unknown

Smith, P.

(45)111-1212

You set the ISearchText text to Smith in order to loop through all the available persons named Smith, but you do not know the first name. You set the INodeOffset to 1 to return their phone numbers, but you do not care about an unknown number.

In this example, this event will be fired three times because there are three nodes that match the criteria set by the control initial properties. If you find the word Unknown in the argument nodeText just simply refuse it by writing this code:

If InStr(1, UCASE(nodeText), "UNKNOWN") < 1 Then
invalidateNode = 1
End If

Note that in the above example, only two results will be actually found by GetNextMatch because ValidateNode is fired during the retrieval of this property.

You could also use CurrentNodeIndex and GetHTMLNodes properties to reveal more about the node that met the criteria and is a candidate to generate a result. For example,. if you want to refuse those nodes that have children nodes, use the following code in this event:

Dim nod As HTMLHtmlElement
Dim nIndx As Integer
nIndx = CurrentNodeIndex(channel)
If nIndex >= 0 Then
 Set nod = GetHTMLNodes(channel, nIndx)
 If nod.children.length > 0 Then
   invalidateNode = 1
 End If
Else
' Should not come to here
End If

Note: Because this event might be fired several times (depending on the number of expected matches in the current document and how many times the result properties are read), you should keep the code to a minimum.

VoiceError

(Channel as Integer, ErrorType as Integer, ErrorData as Integer, Processed as Integer)

This event fires when a non-fatal error occurs in the control. When this error event occurs, the control generating the event is generally not able to continue normal processing. Read more about VoiceError Event.

Read more about WebQuery control.