Friday, May 20, 2005

SQL Server Reporting services Phone Format function

Phone Format: "'Returns formatted Phone Number
Public Function CustomFormat(ByVal Value As String) As String
Dim FormatPhone As String
FormatPhone = Value
Select Case Value.Length
Case 7
FormatPhone = Value.Substring(0, 3) & '-' & Value.Substring(3, 4)
Case 10
FormatPhone = '(' & (Value.Substring(0, 3) & ') ' & Value.Substring(3, 3) & '-' & Value.Substring(6, 4))
Case 12
FormatPhone = ('(' & Value.Substring(0, 3) & ') ' & Value.Substring(4, 3) & '-' & Value.Substring(8, 4))
End Select
Return FormatPhone
End Function"

No comments:

Post a Comment