Regular expressions are a good way to validate text fields such as date,names, addresses, phone numbers, and other user information. You can use the System.Text.RegularExpressions.Regex class for validate any input string for any specific format.
The following example will allow you to Input valid website address only:
Private Sub ValidatewebsiteAddress(ByVal _websiteAddress As String) If Not Regex.IsMatch(_websiteAddress, _ "^((ht|f)tp(s?)\:\/\/|~/|/)?([\w]+:\w+@)?([a-zA-Z]{1}([\w\-]+\.)+([\w]{2,5}))(:[\d]{1,5})?((/?\w+/)+|/?)(\w+\.[\w]{3,4})?((\?\w+=\w+)?(&\w+=\w+)*)?") Then MessageBox.Show("invalid websiteAddress") Else MessageBox.Show("valid websiteAddress") End If End Sub
Pretty good post.
It’s actually a great and useful piece of information. Thanks for sharing.
Very Nice Information thank’s for Share with us