Revision: 3239
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 25, 2007 15:03 by corydeppen
Initial Code
Function formatPhoneNbr(PhoneNbrStr As String) As String
Dim tmpNbr As String
Dim tmpPos As String
Dim tmpLen As Byte
Dim i As Byte
' Get all numbers
For i = 1 To Len(PhoneNbrStr)
tmpPos = Mid(PhoneNbrStr, i, 1)
If IsNumeric(tmpPos) Then
tmpNbr = tmpNbr & tmpPos
End If
Next i
' Get phone number length
tmpLen = Len(tmpNbr)
' Output formatted phone number
Select Case tmpLen
Case 7 ' No area code
formatPhoneNbr = Left(tmpNbr, 3) & "-" & Right(tmpNbr, 4)
Case 10 ' Include area code
formatPhoneNbr = "(" & Left(tmpNbr, 3) & ") " & _
Mid(tmpNbr, 4, 3) & "-" & Right(tmpNbr, 4)
Case Else
formatPhoneNbr = "Invalid Phone Number"
End Select
End Function
Initial URL
Initial Description
Initial Title
Format Phone Number
Initial Tags
Initial Language
Visual Basic