Tuesday, April 29, 2025

Function To Check EIN Validity

     'Function To Check EIN  Validity

    Public Function ValidatePhone(ByVal strEINNum As String) As Boolean

        'Dim EINValid As String = Nothing


        ''Create Reg Exp Pattern

        'Dim strEINPattern As String = "'^\d{2}\-?\d{7}$"

        Dim strEINPattern As String = "^[1-9]\d?-\d{7}$"


        'Create Reg Ex Object

        Dim reEIN As New Regex(strEINPattern)


        'Something Typed In

        If Not String.IsNullOrEmpty(strEINNum) Then


            EINValid = reEIN.IsMatch(strEINNum) 'Check Validity


        Else


            EINValid = False 'Not Valid / Empty


        End If


        Return EINValid 'Return True / False


    End Function