Hello people :) I need some help. How can I get Webbrowser1 to navigate to each page and wait for the one page to completely load, then move to the next page...?

Thank you for answers in advance! ;)


Example.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click



WebBrowser1.Navigate("http://www.google.com") 'Wait for a page to completely load and continue...


WebBrowser1.Navigate("http://www.daniweb.com/forums/")   'Wait for a page to completely load and continue...


WebBrowser1.Navigate("http://msdn.microsoft.com/lt-lt/default(en-us).aspx")     'Wait for a page to completely load and continue...



WebBrowser1.Navigate("http://www.learnvisualstudio.net/")     'Wait for a page to completely load and continue...

End Sub

I tried this, but it doesnt work well.

If WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then
WebBrowser1.Navigate("http://www.learnvisualstudio.net/")
        End If
Member Avatar for Unhnd_Exception

Heres "A" way to do it.

This will navigate back and forth from google.com and yahoo.com, every 10 seconds after the page is loaded.

Public Class Form1
    Private urls() As String = {"http://www.google.com", _
                                "http://www.yahoo.com"}
    Private index As Integer
    Private WithEvents navtimer As New Timer

    Private Sub Form1_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
        navtimer.Interval = 10000
        WebBrowser1.Navigate(urls(index))
        index += 1
    End Sub

    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        lblDone.Text = urls(index - 1)
        navtimer.Start()
    End Sub

    Private Sub navtimer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles navtimer.Tick
        If WebBrowser1.IsBusy Then Exit Sub
        If index > UBound(urls) Then index = 0
        WebBrowser1.Navigate(urls(index))
        index += 1

        navtimer.Stop()
    End Sub
End Class
commented: Thanks for help! :) +0

Thanks man it works great :) +rep

I have a simple question.
I'm making google urls bot and your code it works great,but it
is not in this way i want to.
It loads well but in form load.

Can someone knows how to load and move next page and so on itself and collect all links from google using textbox or listbox in document_complated ?

To make it loop for all google pages like 1,2,3,4,5,6,7,8,9,10 and so on.

Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.