Posted By

blackf0rk on 03/12/09


Tagged

phone number format String


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

haoji


Format a Phone Number


 / Published in: VB.NET
 

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

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.

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

Report this snippet  

You need to login to post a comment.