Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Friday 22 April 2016

How to add email Validation in VBA

Use the following function

Public Function IsEmailValid(strEmail As String) As Boolean
    Dim oRegularExpression As Object
    '   Sets the regular expression object
    Set oRegularExpression = CreateObject("VBScript.RegExp")
    With oRegularExpression
        .Pattern = "^([a-zA-Z0-9_\-\.]+)@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$"
        '   Ignores case
        .IgnoreCase = True
        'Test expression string
        IsEmailValid = .test(strEmail)
    End With
End Function

No comments:

Post a Comment