Function fnValNum(strInput As String) As Boolean
' Uses "Microsoft VBScript Regular Expressions" Type Library
Dim regEx As Object
Set regEx = CreateObject("vbscript.regexp")
regEx.IgnoreCase = True
regEx.Pattern = "([0-9][-.() ]*){10,15}"
fnValNum = regEx.test(strInput) = True
Set regEx = Nothing
End Function
Function fnGetNum(strInput As String, telNum As Boolean) As String
' Uses "Microsoft VBScript Regular Expressions" Type Library
Dim regEx As Object
Dim colMatch As Object
Dim itm As Variant
If fnValNum(strInput) Then
Set regEx = CreateObject("vbscript.regexp")
regEx.IgnoreCase = True
regEx.Global = True
regEx.Pattern = "([0-9][-.() ]*){10,15}"
Set colMatch = regEx.Execute(strInput)
If telNum Then
fnGetNum = colMatch(0)
Else
If colMatch.Count > 1 Then _
fnGetNum = colMatch(1)
End If
End If
Set regEx = Nothing
End Function
|