Question pass chinese word to google

bennettfan

Member
Joined
Jan 31, 2010
Messages
11
Programming Experience
Beginner
WebBrowser1.Navigate("http://www.google.hk/search?hl=en&q=" + txtName.text)

I found that it is work to pass a english word to google but it can not pass chinese word to google....

does anyone have suggestion?
 
The textbox text needs to be url encoded, at least for IE (my FF will accept a Chinese unicode query). Add reference to System.Web and use HttpUtility.UrlEncode function.
 
I have tried it and i add "Imports System.Web" at the top of the code....
However,it said "Type HttpUtility is not defined".

Can anyone help or give me an example?
 
You have not added reference to System.Web like I said.
 
Thanks you so much.

I have tried in this way but it seems that I can't add the reference, can you help?

webv.jpg
 
To add reference use the "add reference" option in Project menu. System.Web is a .Net assembly so you find it in the .Net tab.
 
I have added the reference and the code now is as followed:

" Dim a As HttpUtility = Nothing
Dim input1 As String = "http://www.google.hk/search?hl=en&q=" + finding
Dim reValue As String = Nothing

reValue = a.UrlEncode(input1)
WebBrowser1.Navigate(reValue) "


However, there is error for "reValue = a.UrlEncode(input1)",
the error is
"Access of shared member through an instance; qualifying expression will not be evaluated "....

So, can anyone help??
 
Oh the anguish ;)
VB.NET:
Dim url As String = "http://www.google.hk/search?hl=en&q=" & HttpUtility.UrlEncode(txtName.text)
WebBrowser1.Navigate(url)
 
Back
Top