Resolved Help with Web Browser.

thompse3

Member
Joined
Jul 13, 2009
Messages
6
Programming Experience
Beginner
My problem is that when i click the "go" button it wont load the web page and it gives me this error.
Could some one please help me with this i want the page to load with the "go" button and when you press enter.

I speak french and english.
(Image is french sorry :p )


Heres the code for the "go" button.
VB.NET:
Private Sub ToolStripButton6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton6.Click
        WebBrowser1.Navigate(url.Text)
    End Sub
---------------------
It loads the page when i press enter (on the keyboard) tho.

VB.NET:
Private Sub url_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles url.KeyDown, ToolStripButton6.Click
        If e.KeyCode = Keys.Enter Then
            WebBrowser1.Navigate(url.Text)
        End If



    End Sub

I would love a reply.

EDIT: I think im in the wrong section... :(
 
Last edited:
The problem is you added the button click event to the keydown event, they have different signatures.
VB.NET:
Private Sub url_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles url.KeyDown [FONT="Courier New"][B][COLOR="Red"], ToolStripButton6.Click[/COLOR] [/B][/FONT]
        If e.KeyCode = Keys.Enter Then
            WebBrowser1.Navigate(url.Text)
        End If
End Sub

Remove the red part.

Click event signature is (ByVal sender As Object, ByVal e As EventArgs)
Keydown event is (ByVal sender As Object, ByVal e As KeyEventArgs)
 

Latest posts

Back
Top