如何判断WebBrowser1_DocumentComplete过程已经完成?
Private Sub Command1_Click()
For i = Text5 To Text6
Text2 = Text7 & i
WebBrowser1.Navigate Text2
Call Command2_Click'这里我希望的是WebBrowser1_DocumentComplete过程完成后再执行,可是现在这个代码根本就不会执行command2_click,直接就把循环语句给循环完了.如何判断WebBrowser1_DocumentComplete事件已经完成呢?WebBrowser1_DocumentComplete事件又不能被调用. 我本来想干脆把call Command2_Click放到WebBrowser1_DocumentComplete过程里去,但是webbrowser1在Formload的时候访问的是about blank,程序启动的时候Set Acollection = webdoc.All.tags("a")
会出错自动退出. 我想在这句前面加个判断,等WebBrowser1_DocumentComplete过程执行完毕再执行这里这句
Next i
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
List1.Clear
List3.Clear
List2.Clear
Set webdoc = WebBrowser1.Document
Dim Acollection As IHTMLElementCollection
Set Acollection = webdoc.All.tags("a")
For i = 0 To Acollection.length - 1
List1.AddItem Acollection.Item(i).toString
List3.AddItem Acollection.Item(i).innerText
If List3.List(i) = "1" Then
List2.AddItem List1.List(i)
End If
Next
-----------------------
多谢!!
[解决办法]
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)msgbox urlif url="about blank" then exit subIf not(pDisp Is WebBrowser1.Object) Then exit subList1.ClearList3.ClearList2.ClearSet webdoc = WebBrowser1.DocumentDim Acollection As IHTMLElementCollectionSet Acollection = webdoc.All.tags("a")For i = 0 To Acollection.length - 1 List1.AddItem Acollection.Item(i).toString List3.AddItem Acollection.Item(i).innerTextIf List3.List(i) = "1" ThenList2.AddItem List1.List(i) End IfNext