0

net web browser and im in sort of trouble. I want to let user write url or search query in same textbox , something like its ie. in google chrome. I have an idea but im open to others too

Basically my solve is to check that text has something like domain i mean it has "." and 3 or 2 any letters.

  • Welcome to Stack Overflow. I would suggest that you provide us with some code so we can see exactly what it is you are trying to do. We like specific detail on here, but only relevant detail of course. – McMath Feb 23 '16 at 21:21

2 Answers2

0

you can use regex to check if the inputted string is a url (see this question).

see here for a tutorial on regex in VB.Net

If not a url, do your typical search :)

Community
  • 1
  • 1
Noam Hacker
  • 3,845
  • 7
  • 30
  • 52
0

ok, i tried to use some regex but there is one thing. i used this regex:

"^http://[a-zA-Z0-9-.]+.[a-zA-Z]{2,3}(/\S*)?$"

and there is my code

Dim r As Regex = New Regex("^http\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?$")
    Dim match As Match = r.Match(TextBox1.Text.ToString, RegexOptions.IgnoreCase)
    If GetAsyncKeyState(13) Then
        If match.Success Then
            navigate(TextBox1.Text, WebControl1)
        Else
            navigate("http://www.google.com/search?q=" + TextBox1.Text, WebControl1)
        End If
    End If

but the issue is that no matter what i put to textbox1 it actually searchs it like in else statement