Answered by:
How to display text from TextBox in VB to TextBox of Google?

Question
-
I'm using VB2008
How to display text from TextBox in VB to TextBox in Web browser Google on the internetTuesday, January 17, 2012 7:58 AM
Answers
-
Hi Bhd9,
Do you mean to search the text in textbox with Google? If so, you could get the text of the textbox first ,then use the WebBrowser.Navigate to open the destination URL in webBrowser control . Also, you could open the URL in web browser application(specified or default). And here is the code snip of example:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim urlString As String = "https://www.google.com/search?q=" & TextBox1.Text.Trim() & "&&qscrl=1"
'open it in webBrowser control
WebBrowser1.Navigate(urlString)
'Or open it in web browser application
System.Diagnostics.Process.Start(urlString)
'System.Diagnostics.Process.Start("IEXPLORE.EXE", urlString)
End Sub
If I misunderstood anything, please feel free and let me know.
Best regards,
Shanks Zen
MSDN Community Support | Feedback to us
Friday, January 20, 2012 1:43 AM -
Hi Bhd,
Sorry for my late reply.
The exception was thrown because in runtime, when run into this line WebBrowser1.Document.GetElementById("email").InnerText = "YourEmail@Company.com" , the webbrowser URL hadn't loaded completely. So you have to wait the page loaded completely then set the email and passWord.
If anything is unclear, please feel free and let me know.
Best regards,
Shanks Zen
MSDN Community Support | Feedback to us
- Marked as answer by bhd9 Friday, February 3, 2012 6:28 PM
Friday, February 3, 2012 7:54 AM
All replies
-
Take a look at this official Page from Google which describes it,
http://code.google.com/apis/customsearch/docs/api.html
to do those commands from a desktop you need the System Net namespace, in particulary the webrequest and the webresponse.
http://msdn.microsoft.com/en-us/library/system.net.aspx
Success
CorTuesday, January 17, 2012 8:04 AM -
The first code show this error
403. <ins>That’s an error.</ins>
Your client does not have permission to get URL
/apis/customsearch/docs/api.html
from this server. <ins>That’s all we know.</insI'm using visual studio 2008 -vb
I tired this code. the problem is :
Namespace .....SHDocVw doesn't contain any ...memmber
and I dont' know how to complete the code
Dim objIE As SHDocVw.InternetExplorer objIE = CreateObject("InternetExplorer.Application") objIE.Navigate("http://Google.com") objIE.Visible = True objIE..document....= TextBox1.Text
- Edited by bhd9 Tuesday, January 17, 2012 9:52 AM
Tuesday, January 17, 2012 9:12 AM -
I'm using visual studio 2008 -vb
I tired this code. the problem is :
and I dont' know how to complete the code
Dim objIE As SHDocVw.InternetExplorer objIE = CreateObject("InternetExplorer.Application") objIE.Navigate("http://Google.com") objIE.Visible = True objIE..document....= TextBox1.Text
Wednesday, January 18, 2012 3:00 PM -
Hi Bhd9,
Do you mean to search the text in textbox with Google? If so, you could get the text of the textbox first ,then use the WebBrowser.Navigate to open the destination URL in webBrowser control . Also, you could open the URL in web browser application(specified or default). And here is the code snip of example:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim urlString As String = "https://www.google.com/search?q=" & TextBox1.Text.Trim() & "&&qscrl=1"
'open it in webBrowser control
WebBrowser1.Navigate(urlString)
'Or open it in web browser application
System.Diagnostics.Process.Start(urlString)
'System.Diagnostics.Process.Start("IEXPLORE.EXE", urlString)
End Sub
If I misunderstood anything, please feel free and let me know.
Best regards,
Shanks Zen
MSDN Community Support | Feedback to us
Friday, January 20, 2012 1:43 AM -
What if I want to use it with anohter site has many textbox like FaceBook example
I used this code in VBA Excel and it work.by the way I got the name of email TexBox and pass TexBox fro source code of page.
can I creat like this code in the Vb.net?
Set app = CreateObject("INTERNETEXPLORER.APPLICATION") app.navigate "http://www.facebook.com" app.Visible = True Do Until app.readystate = 4 DoEvents Loop With app.document.forms(0) .all("email").Value = "MyName" .all("pass").Value = "MyPaasword" End With
Friday, January 20, 2012 1:49 PM -
Hi Bhd9,
You could add the following code in the event DocumentCompleted to achieve your goal.
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
WebBrowser1.Document.GetElementById("email").InnerText = "YourEmail@Company.com"
WebBrowser1.Document.GetElementById("pass").InnerText = "YourPassword"
End Sub
If you have anything unclear, please feel free and let me know.
Best regards,
Shanks Zen
MSDN Community Support | Feedback to us
Monday, January 23, 2012 8:59 AM -
I'm confusing about it. I tried it by another way, by add to Form Control WebBrowser
and tried it but it showed me this error: Object reference not set to an instance of an object.
WebBrowser1.Navigate("http://www.facebook.com") WebBrowser1.Document.GetElementById("email").InnerText = "YourEmail@Company.com" WebBrowser1.Document.GetElementById("pass").InnerText = "YourPassword"
Tuesday, January 24, 2012 3:59 PM -
Hi Bhd,
Sorry for my late reply.
The exception was thrown because in runtime, when run into this line WebBrowser1.Document.GetElementById("email").InnerText = "YourEmail@Company.com" , the webbrowser URL hadn't loaded completely. So you have to wait the page loaded completely then set the email and passWord.
If anything is unclear, please feel free and let me know.
Best regards,
Shanks Zen
MSDN Community Support | Feedback to us
- Marked as answer by bhd9 Friday, February 3, 2012 6:28 PM
Friday, February 3, 2012 7:54 AM -
Thank you very mush for help!!!
Friday, February 3, 2012 6:42 PM