How to check If a string is a valid URL in VB.NET

1 Answer

0 votes
Imports System

Public Class Program
	Public Shared Function ValidateURL(ByVal url As String) As Boolean
        Return Uri.IsWellFormedUriString(url, UriKind.Absolute)
    End Function

    Public Shared Sub Main()
        Dim url As String = "https://www.shortinfos.com/"
        Dim isValidURL As Boolean = ValidateURL(url)
        Console.WriteLine(isValidURL)
		
        Console.WriteLine(ValidateURL("https://seek4info.com/search.php?query=web+hosting"))
    End Sub
End Class



' run:
'
' True
' True
'

 



answered Aug 13, 2023 by avibootz

Related questions

...