codedog 0 Newbie Poster

Hi,
This works every other time. I'm trying to send data to a web page. When I click on button2 nothing happens. click again and the data shows up on the web page. click nothing, click data.
What am I doing wrong?

The form is a pannel (dock=top) and webrowser (doc=fill)
two buttons and two textboxes are on the pannel.

Thanks

Public Class Form1
    Public cntr As Integer = 0
    Public Sub New()
        ' This call is required by the Windows Form Designer.
        InitializeComponent()
        Me.TextBox1.Text = "http://www.google.com/"
        Me.TextBox2.Text = "X"
        ' Add any initialization after the InitializeComponent() call.
    End Sub
    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        WebBrowser1.Navigate(TextBox1.Text)
    End Sub
    Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
        WebBrowser1.Focus()
        If WebBrowser1.Focused Then
            cntr = cntr + 1
            SendKeys.Send(cntr & TextBox2.Text)
        Else
            MsgBox("not focused")
        End If
    End Sub
End Class