-5

I found following code from this link.

https://msdn.microsoft.com/en-us/library/01escwtf(v=vs.80).aspx

Function IsValidEmail(strIn As String) As Boolean
' Return true if strIn is in valid e-mail format.
Return Regex.IsMatch(strIn, "^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$")
End Function

I dont know how to use above code. I mean how to call above code?

  • 1
    http://stackoverflow.com/q/201323/1070452 – Ňɏssa Pøngjǣrdenlarp Nov 30 '16 at 16:36
  • 1
    To use it, you probably have to import System.Text.RegularExpressions, and then just call it like: If IsValidEmail("me@domain.com") Then... – soohoonigan Nov 30 '16 at 16:42
  • 1
    The code you posted is a function that takes a `String` as input and returns a `Boolean` to indicate if the format is valid for an e-mail address. – Blackwood Nov 30 '16 at 16:42
  • Update title of the question - it is misleading for people who answers only based on title :) – Fabio Nov 30 '16 at 16:48
  • The same. `If IsValidEmail("somebody@somewhere.com") Then `valid format`. – Blackwood Nov 30 '16 at 16:49
  • 1
    The page you referring to is obsolete and provide a link to newer version with code examples: [https://msdn.microsoft.com/en-us/library/01escwtf(v=vs.110).aspx](https://msdn.microsoft.com/en-us/library/01escwtf(v=vs.110).aspx) – Fabio Nov 30 '16 at 16:50

1 Answers1

1

you can use it as below

If IsValidEmail("inputemail@domain.com") Then
        'valid email
Else
       'invalid email
End If
Damith
  • 62,401
  • 13
  • 102
  • 153