converting phone numbers

Bryan

Freshman
Joined
Jun 17, 2002
Messages
49
Location
Cedar Hill, TX
does anybody have a code fragment or something that will allow me to extract the parenthesis, dashes, etc from a phone number and just have the actual numerical digits. So if I had a phone number of (123)456-7890 and ran the code it would output 123456789?
 
Use the Replace function of the String object.

Visual Basic:
Dim PhoneNum As String = "(123)456-7890"

PhoneNum = PhoneNum.Replace("(","") ' Replace ( with an empty string

PhoneNum = PhoneNum.Replace(")","") ' Replace ) with an empty string

... and so on and so forth, for all the strings you want to remove.
You may also want to consider removing spaces if there is the
chance they will show up.
 
Back
Top