WebBrowser Control

  • Thread starter Thread starter Lance
  • Start date Start date
L

Lance

Hi All,

Given a collection of links, how can I send them to a WebBrowser Control so
that I can manipulate it's document? Ok, that's way too simplified of a
question. I know how to send a link to a WebBrowser:

/////
WebBroweser1.Navigate(Link)
/////

but I can figure out how to send several links in succession. In my test,
I've got a simple collection that contains 5 strings. Pressing a command
button performs:

/////
For Each s As String In links
WebBrowser1.Navigate(s)
Next
/////

and in the WebBrowser1's DocumentCompleted Event is:

/////
Dim doc As HtmlDocument = WebBrowser1.Document
Debug.Print(doc.Url.ToString)
/////

However, the only Url string ever printed to the immediate window is the
last one in the collection, and all the WebBrowser1 window ever shows is
that last webpage.

I realize this probably has something to do with synchronization, but I'm
not sure how to resolve this.

Thanks,
Lance
 
Hello Lance" chuckyboy81070-at-onehotpotatoimeanhotmail.com,

..Navigate() is an asynch method. The navigation and remdering is passed
off to the web browser control, which uses a separate thread(s) to do the
work.. and immediately returns from the .Navigate method.

The correct method for navigating multiple URLs in succession.. which you
should have guessed from your investigations had you just applied yourself..
is to navigate to each successive URL from within the DocumentCompleted event.

-Boo
 
Thanks Boo. You're right, I would have eventually figured that out. I
tried for several hours and just thought I'd drop a note to the group before
the weekend.

Thanks again,
Lance
 
Back
Top