Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • June 26, 2016, 03:11:13 AM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Launching Google search in Visual Basic - Help?  (Read 5616 times)

wreckedcarzz

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 1,623
    • View Profile
    • Read more about this member.
    • Donate to Member
Launching Google search in Visual Basic - Help?
« on: March 31, 2008, 05:12:11 PM »
Hey everybody,

Using the WebBrowser control, I had an issue getting a search box (returning a Null variable value). I changed it to search directly (via Google) however VB doesn't want to pass the user's search terms into the Google URL that I have. Tried quotes in every logical location, changed variables, used the {} brackets (not sure what they are called) around the variable... nothing works.

The search box (basic text box) is called txtSearch, and the variable is WebSearch. Here is the code...

    Private Sub DoSearch()
        Dim WebSearch As String
        WebSearch = txtSearch.Text
        AppManager.CurrentBrowser.Navigate("http://www.google.com/search?hl=en&q=", txtSearch.Text)
    End Sub

The browser WILL go to the page, but ONLY the Google home page (because there is no search term being sent).

Can anyone help me out? It has to be simple, but I simply cannot get it! >:( :tellme:

-Brandon

jazper

  • Coding Snacks Author
  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 92
    • View Profile
    • Jazper's Software
    • Donate to Member
Re: Launching Google search in Visual Basic - Help?
« Reply #1 on: March 31, 2008, 08:20:39 PM »
The second argument in the navigate method is:

Quote
targetFrameName
Type: System.String

The name of the frame in which to load the document

Were you thinking it would to concatenate it to the 1st arguement?

wreckedcarzz

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 1,623
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Launching Google search in Visual Basic - Help?
« Reply #2 on: March 31, 2008, 10:43:11 PM »
I didn't really understand what you were trying to say (its been a long day) but the browser does go to Google - it just doesn't enter the text that would logically go where txtSearch.Text is (ex: http://www.google.co.../search?hl=en&q=My Awesome Search) so it (Google) kicks me back.

(Click link to see example)
« Last Edit: March 31, 2008, 10:45:26 PM by wreckedcarzz »

jazper

  • Coding Snacks Author
  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 92
    • View Profile
    • Jazper's Software
    • Donate to Member
Re: Launching Google search in Visual Basic - Help?
« Reply #3 on: March 31, 2008, 11:33:48 PM »
I didn't really understand what you were trying to say (its been a long day) but the browser does go to Google - it just doesn't enter the text that would logically go where txtSearch.Text is (ex: http://www.google.co.../search?hl=en&q=My Awesome Search) so it (Google) kicks me back.

(Click link to see example)

Yes, but what exactly do you think the second argument in
        AppManager.CurrentBrowser.Navigate("http://www.google.co.../search?hl=en&q=", txtSearch.Text)

is doing??  Did you expect it to concatenate/append to the first argument?


wreckedcarzz

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 1,623
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Launching Google search in Visual Basic - Help?
« Reply #4 on: April 01, 2008, 12:14:29 AM »
Yes, exactly - I figured it would (logically) work as the parameters do when launching programs (just addon) - Obviously I am incorrect, but that was my hypothesis.

Wibble

  • Participant
  • Joined in 2009
  • *
  • Posts: 1
    • View Profile
    • Donate to Member
Re: Launching Google search in Visual Basic - Help?
« Reply #5 on: February 05, 2009, 03:44:26 PM »
A simple way of doing that of course for google is:
Quote
WebBrowser1.Navigate("http://www.google.co.../search?hl=en&q=" + searchTextBox.Text)
Or for wikipedia:
Quote
WebBrowser2.Navigate("http://en.wikipedia.org/wiki/" + searchTextBox.Text)

Don't forget to change the red text to the search textbox and the green to the web browser.

I know its realy spimple but it works for me when i put it on a button.  :Thmbsup:
« Last Edit: February 05, 2009, 03:47:45 PM by Wibble »

wreckedcarzz

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 1,623
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Launching Google search in Visual Basic - Help?
« Reply #6 on: February 06, 2009, 05:27:34 PM »
Ah, alright, I'll have to try that. I managed to get Google working a while back, but the WikiPedia one is definitely cool!

Thanks for the info! :)