By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,058 Members | 1,336 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,058 IT Pros & Developers. It's quick & easy.

how to execute a google search ?

100+
P: 133
Hello all,

I am trying to learn how to change the google search query with-in VB6 ,
in this search it is obvious that it is searching the word frog
i would like to know how to use a textbox as the souce of the query.

Sub Command1_click()

shell "C:\Program Files\Internet Explorer\IEXPLORE.EXE
http://www.google.com.au/search?hl=en&q=frog&meta="

End Sub

Thankyou for any help it will be much appreciated.
Gobblegob.
Dec 12 '07 #1
Share this Question
Share on Google+
9 Replies


debasisdas
Expert 5K+
P: 8,127
You need to capture all the individual word separately from user input. Then run the query using like search after eleminating unnecessary word.
Dec 12 '07 #2

100+
P: 133
You need to capture all the individual word separately from user input. Then run the query using like search after eleminating unnecessary word.
Thanks for your reply but umm... i dont know how to do it, im after an example to learn from.

Thanks
Gobblegob.
Dec 12 '07 #3

QVeen72
Expert 100+
P: 1,445
Hi,

It is easy if you are using a Webrowser Control,
say, you want to search for VB6 and DataGrid:
Write this Code in CommandSearch_Click event

Expand|Select|Wrap|Line Numbers
  1. WebBrowser1.Navigate2 "http://www.google.co.in/search?hl=en&q=VB6+DATAGRID&meta="
  2. DoEvents
  3.  

Regards
Veena
Dec 12 '07 #4

100+
P: 133
Hi,

It is easy if you are using a Webrowser Control,
say, you want to search for VB6 and DataGrid:
Write this Code in CommandSearch_Click event

Expand|Select|Wrap|Line Numbers
  1. WebBrowser1.Navigate2 "http://www.google.co.in/search?hl=en&q=VB6+DATAGRID&meta="
  2. DoEvents
  3.  

Regards
Veena

Thanks but i understand that im trying to use a textbox as the search input on the VB6 form

Thanks
Gobblegob.
Dec 12 '07 #5

QVeen72
Expert 100+
P: 1,445
Hi,

OK, Say you have to search from textbox Text1
use this Code:

Expand|Select|Wrap|Line Numbers
  1. Dim TArr
  2. Dim TempStr As String
  3. Dim i As Integer
  4. TArr = Split(UCase(Text1.Text)," ")
  5. TempStr = "=" 
  6. For i = LBound(TArr) To UBound(TArr)
  7.    If Trim(TArr(i)) <> "" Then
  8.        If i = UBound(TArr) Then
  9.          TempStr =TempStr TArr(i)
  10.       Else 
  11.          TempStr =TempStr TArr(i) & "+"
  12.       End If
  13.    End If
  14. Next 
  15. TempStr = "http://www.google.co.in/search?hl=en&q" & TempStr & "&meta="
  16. WebBrowser1.Navigate2 TempStr
  17. DoEvents
  18.  

Refine the code..

Regards
Veena
Dec 12 '07 #6

100+
P: 133
Hi,

OK, Say you have to search from textbox Text1
use this Code:

Expand|Select|Wrap|Line Numbers
  1. Dim TArr
  2. Dim TempStr As String
  3. Dim i As Integer
  4. TArr = Split(UCase(Text1.Text)," ")
  5. TempStr = "=" 
  6. For i = LBound(TArr) To UBound(TArr)
  7.    If Trim(TArr(i)) <> "" Then
  8.        If i = UBound(TArr) Then
  9.          TempStr =TempStr TArr(i)
  10.       Else 
  11.          TempStr =TempStr TArr(i) & "+"
  12.       End If
  13.    End If
  14. Next 
  15. TempStr = "http://www.google.co.in/search?hl=en&q" & TempStr & "&meta="
  16. WebBrowser1.Navigate2 TempStr
  17. DoEvents
  18.  

Refine the code..

Regards
Veena

Thanks for your post Veena,

but i am getting a syntax error on

TempStr =TempStr TArr(i)
Else
TempStr =TempStr TArr(i) & "+"

i've looked at it over and over but i cant see why if , if you wouldnt mind talkin me through it i would be very greatfull.

Thanks ,
Gobblegob.
Dec 13 '07 #7

100+
P: 133
Thanks for your post Veena,

but i am getting a syntax error on

TempStr =TempStr TArr(i)
Else
TempStr =TempStr TArr(i) & "+"

i've looked at it over and over but i cant see why if , if you wouldnt mind talkin me through it i would be very greatfull.

Thanks ,
Gobblegob.
I worked it out all i used is this:

Dim TempStr As String
Dim TempText As String
TempText$ = Text1.Text
TempStr = "http://www.google.com.au/search?hl=en&q" & "=" & TempText & "&meta="
WebBrowser1.Navigate2 TempStr

Thanks for your help,
Gobblegob.
Dec 13 '07 #8

P: 1
This is easy:

Create a text box named Textbox1

Create a web browser named webbrowser1

Create a button called Button1. This will be your "Search" button.

Copy this code



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

Dim search As String = TextBox1.Text

WebBrowser1.Navigate ("www.google.com.au/search?hl=en&q=" + search + "&meta=")

End Sub



Easy as that!
Jan 23 '08 #9

P: 58
In VBA.

Expand|Select|Wrap|Line Numbers
  1. Sub Main()
  2.    Dim IE As Object, web_site As String
  3.  
  4.    web_site = "http://www.google.com"
  5.  
  6.    Set IE = CreateObject("InternetExplorer.Application")
  7.  
  8.    With IE
  9.       .Visible = True
  10.       .Navigate web_site
  11.    End With
  12.  
  13.    Call Wait(IE)
  14.  
  15.    IE.Document.All("q").Value = "Test"
  16.    IE.Document.All("btnG").Click
  17.  
  18.    Call Wait(IE)
  19. End Sub
  20.  
  21. Private Sub Wait(IE As Object)
  22.    While IE.Busy
  23.       DoEvents
  24.    Wend
  25.  
  26.    While IE.Document.ReadyState <> "complete"
  27.       DoEvents
  28.    Wend
  29. End Sub
Jan 23 '08 #10

Post your reply

Sign in to post your reply or Sign up for a free account.