Monday, December 29, 2008

Format a Phone Number

Dim pn As String = "(444) 444-444"
Dim newPn As String = Replace(Replace(Replace(pn, "-", ""), "(", ""), ")", "")
newPn = String.Format("{0:###-###-####}", Convert.ToInt64(newPn))


It's important that the newPn var that you pass into the Convert.ToInt64 function is in the xxxxxxxxxx format and that no characters are present.

No comments: