Return to Snippet

Revision: 12389
at March 12, 2009 17:12 by blackf0rk


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

Initial URL
http://codefinds.blogspot.com/2008/12/format-phone-number.html

Initial Description
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.

Initial Title
Format a Phone Number

Initial Tags
phone, number, format

Initial Language
VB.NET