I am working on a web browser in Visual basic 2010 and I was wondering if there is any way I could search and navigate in the same textbox. I know it can be done because I have seen it done before but I do not know how to do it. If you are not sure what I am talking about, I am talking about typing something into the url bar that you want to search and hitting enter to search just like in chrome but also being able to type in a url and hit enter and go to that url. I already have the keydown event for the textbox and it is all set up to navigate but it don't search. What would be the best way to search?
I have actually found a better way to do this. The token was a good idea but it became easy to forget. The way I am doing it now:
Dim textArray = AddressBar.Text.Split(" ")
If (AddressBar.Text.Contains(".") AndAlso
Not AddressBar.Text.Contains(" ") AndAlso
Not AddressBar.Text.Contains(" .") AndAlso
Not AddressBar.Text.Contains(". ")) OrElse
textArray(0).Contains(":/") OrElse textArray(0).Contains(":\") Then
'We have an URL!
End If
As you can see this method checks for everything a normal URL could have in it and if it has those then the browser navigates but if it doesn't have those the browser searches google. I have yet to find anything that could be searched but the browser thinks is a URL. if you find something please let me know so I can work on fixing it.
Thanks Jeff Bridgman for your improved code.