0
    Private Sub RefreshGoSearchCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RefreshGoSearchCancel.Click
        If (AddressBar.Text = "") Then
            WebBrowser.Refresh()
        ElseIf (AddressBar.Text <> "" And "." And "") Then
            WebBrowser.Navigate("www.google.com/search?q=" & AddressBar.Text)
        Else
            WebBrowser.Navigate(AddressBar.Text)
        End If
    End Sub

This is the code for The AddressBar to refresh when text hasn't changed, search when there is no website prefix and navigate to a web address when ther is. A runtime error is showing up any help?

3
Contributors
3
Replies
6
Views
4 Years
Discussion Span
Last Post by AleMonteiro
2

ElseIf (AddressBar.Text <> "" And "." And "") Then

You will have to write it like this

ElseIf (AddressBar.Text <> "" And AddressBar.Text <> ".") Then

you were comparing string only once.

Edited by Sahil89

2

I'd say the best way to handle the address bar text is using Regular Expression.

Or if just want to check if it's a valid URI, use this: Uri.IsWellFormedUriString(YourURLString, UriKind.RelativeOrAbsolute)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.