EMAILVALID
Returns whether a string is a valid email address.
Remarks
* For instructions on how to add a function to a workbook refer to the page under Inserting Functions
* The equivalent JavaScript function is EMAILVALID
Public Function EMAILVALID(ByVal sEmailAddress As String) As Boolean
Dim sEmailPattern1 As String
Dim sEmailPattern2 As String
Dim oRegEx As Object
Dim bReturn As Boolean
sEmailPattern1 = "^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$"
Set oRegEx = CreateObject("VBScript.RegExp")
oRegEx.Global = True
oRegEx.IgnoreCase = True
oRegEx.Pattern = sEmailPattern1
bReturn = False
If (oRegEx.Test(sEmailAddress) = True) Then
sEmailPattern2 = "^([a-zA-Z0-9_\-\.]+)@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$"
Set oRegEx = CreateObject("VBScript.RegExp")
oRegEx.Global = True
oRegEx.IgnoreCase = True
oRegEx.Pattern = sEmailPattern2
bReturn = False
If (oRegEx.Test(sEmailAddress) = True) Then
bReturn = True
Else
bReturn = False
End If
Else
bReturn = False
End If
EMAILVALID = bReturn
End Function
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext