Confused ?!?!

Aspen2K
10-04-2001, 08:46 AM
Hello, I'm quite confused as to why the code below only adds the links from the last url in list2. Why is it not collecting all the other urls links? Thank you.

Option Explicit

Private Sub Command1_Click()
Dim x As Long
Command1.Enabled = False
For x = 0 To List2.ListCount - 1
WebBrowser2.Navigate2 List2.List(x)
Next x
End Sub

Private Sub Command2_Click()
List2.AddItem "http://" & txtaddurl.Text
txtaddurl.Text = ""
End Sub

Private Sub WebBrowser2_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Dim x As Long
For x = 0 To WebBrowser2.Document.Links.length - 1
List1.AddItem WebBrowser2.Document.Links.Item(x)
Next x
Command1.Enabled = True
End Sub

Private Sub WebBrowser2_StatusTextChange(ByVal Text As String)
Label3 = Text
End Sub

Ad1
10-04-2001, 08:59 AM
because the document complete event only fires when the document is complete
try sticking this liitle loop in your for loop in command1_click
<pre>do
loop while webbrowser2.busy</pre>
and then in your document_complete put
<pre>List1.AddItem WebBrowser2.LocationURL</pre>

Aspen2K
10-04-2001, 09:33 AM
Thanks for the reply Ad1, however when adding these couple lines the program seems to lock up. Below is what I have now, Did I put them in the wrong place ?

Private Sub Command1_Click()
Dim x As Long

Command1.Enabled = False

For x = 0 To List2.ListCount - 1
Do
Loop While WebBrowser2.Busy
WebBrowser2.Navigate2 List2.List(x)
Next x

End Sub

Private Sub WebBrowser2_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Dim x As Long
List1.AddItem WebBrowser2.LocationURL

For x = 0 To WebBrowser2.Document.Links.length - 1
List1.AddItem WebBrowser2.Document.Links.Item(x)
Next x
Command1.Enabled = True

End Sub

Ad1
10-04-2001, 09:43 AM
just needed to swap a few bits around
<pre><font color=blue>Private Sub</font color=blue> Command1_Click()

<font color=blue>Dim</font color=blue> x <font color=blue>As Long</font color=blue>

<font color=blue>For</font color=blue> x = 0 <font color=blue>To</font color=blue> List2.ListCount - 1
WebBrowser2.Navigate2 List2.List(x)
<font color=blue>Do</font color=blue>
DoEvents
<font color=blue>Loop While</font color=blue> WebBrowser2.Busy
<font color=blue>Next</font color=blue> x

<font color=blue>End Sub</font color=blue>

<font color=blue>Private Sub</font color=blue> WebBrowser2_DocumentComplete(<font color=blue>ByVal</font color=blue> pDisp <font color=blue>As Object</font color=blue>, URL <font color=blue>As Variant</font color=blue>)

<font color=blue>Dim</font color=blue> x <font color=blue>As Long</font color=blue>

List1.AddItem WebBrowser2.LocationURL

<font color=blue>End Sub</font color=blue></pre>

Aspen2K
10-04-2001, 09:51 AM
Ahhh ha. Tis it. I thank you very much for your help Ad1.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum