Fire NavigateError event for webbrowser

Hopefully this will b esomething simple.

I'm able to navigate easily - but I want to capture errors.  Neither of these events will fire, and I don't know why.   I have IE 6 on my machine, and VB .NET 2003.


private sub loadSite()
        Try
            AxWebBrowser1.Navigate2("http://www.yahoo.com", , , vPost, vHeaders)
            'Do While AxWebBrowser1.Busy
            'Application.DoEvents()
            'Loop

        Catch ex As Exception
            MsgBox("didn't get it")
            AxWebBrowser1.Visible = False
        End Try
end sub


Private Sub AxWebBrowser1_NavigateError(ByVal pDisp As Object, ByVal URL As Object, _
    ByVal TargetFrameName As Object, ByVal StatusCode As Object, ByRef Cancel As Boolean)
        MsgBox("navigator error")
End Sub

Private Sub AxWebBrowser1_DocumentComplete(ByVal pDisp As Object, ByVal URL As Object, ByVal Frame As Object, ByVal StatusCode As Object, ByVal Cancel As Boolean)
        MsgBox("doc complete")
End Sub
maxout69Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CKIECommented:
You need to add a Handles to you events

i.e.

Private Sub AxWebBrowser1_DocumentComplete(ByVal pDisp As Object, ByVal URL As Object, ByVal Frame As Object, ByVal StatusCode As Object, ByVal Cancel As Boolean) Handles  AxWebBrowser1.DocumentComplete
       MsgBox("doc complete")
End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CKIECommented:
also make sure AxWebBrowser1 is declared with the WithEvents keyword.

i.e.
Friend WithEvents AxWebBrowser1 as Object
maxout69Author Commented:
Already had the second:
Friend WithEvents AxWebBrowser1 As AxSHDocVw.AxWebBrowser

I was missing the handles event.  This is what finally worked (note the different parameters):

    Private Sub AxWebBrowser1_NavigateError(ByVal sender As Object, ByVal e As _
AxSHDocVw.DWebBrowserEvents2_NavigateErrorEvent) Handles AxWebBrowser1.NavigateError
        MsgBox("navigator error")
    End Sub
    Private Sub AxWebBrowser1_DocumentComplete(ByVal sender As Object, ByVal e As _
        AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent) Handles AxWebBrowser1.DocumentComplete
        MsgBox("doc complete")
    End Sub
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.