Function FormatPhoneNumbers(ByVal strInputPhoneNumber As String) As String
'Strip off the ( , ) and -
Dim strPhoneNumber As String
strInputPhoneNumber = strInputPhoneNumber.Replace(" ", "")
strInputPhoneNumber = strInputPhoneNumber.Replace("(", "")
strInputPhoneNumber = strInputPhoneNumber.Replace(")", "")
strInputPhoneNumber = strInputPhoneNumber.Replace("-", "")
'Now format it
If strInputPhoneNumber.Length >= 3 Then
strPhoneNumber = "(" & strInputPhoneNumber.Substring(0, 3) & ") "
If strInputPhoneNumber.Length < 6 Then
strPhoneNumber = strPhoneNumber & strInputPhoneNumber.Substring(3,
strInputPhoneNumber.Length - 3)
Else
strPhoneNumber = strPhoneNumber & strInputPhoneNumber.Substring(3,
3) & "-" & strInputPhoneNumber.Substring(6)
End If
End If
Return strPhoneNumber
End Function