This function validates fax or phone numbers.
This function validates fax or phone numbers.
Rate This function validates fax or phone numbers.
(1(1 Vote))
Dim strCurrentChar As String
Dim lngIndex As Long
ValidatePhone = True
strPhone = Trim(strPhone)
'If Phone is not at least (012)345-6789 long
If Len(strPhone) <> 13 Then GoTo Fail_Validation
strCurrentChar = Left(strPhone, 1)
If strCurrentChar <> "(" Then GoTo Fail_Validation
strCurrentChar = Mid(strPhone, 5, 1)
If strCurrentChar <> ")" Then GoTo Fail_Validation
strCurrentChar = Mid(strPhone, 9, 1)
If strCurrentChar <> "-" Then GoTo Fail_Validation
For lngIndex = 1 To Len(strPhone)
strCurrentChar = Mid(strPhone, lngIndex, 1)
Select Case Asc(strCurrentChar)
Case 1 To 31, 33 To 39, 42, 44, 46, 58 To 255
GoTo Fail_Validation
End Select
Next lngIndex
ValidatePhone_Exit:
Exit Function
Fail_Validation:
ValidatePhone = False
GoTo ValidatePhone_Exit
End Function
This function validates fax or phone numbers. Comments
No comments yet — be the first to post one!
Post a Comment