Pages

Wednesday, 11 July 2012

Google Search Using VB.NET

This tutorial is going to tech you how to make simple Google Search Application using VB.NET. In this tutorial we are using Timer to control the Google Search appropriate manner. We are also using VB.NET WebBrowser control to navigate and search, so before trying this code you have to add WebBrowser control to your form from Toolbar shown in figure given below:

Add WebBrowser



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

        Timer1.Interval = 500
        Timer1.Enabled = True
        Timer1.Start()
        WebBrowser1.Navigate("http://www.google.com/")

End Sub


Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        If WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then
            Timer1.Stop()
            WebBrowser1.Document.GetElementById("q").SetAttribute("value", "VB.NET Tutorials")
            WebBrowser1.Document.GetElementById("btnk").InvokeMember("click")
        End If

End Sub