473,326 Members | 2,255 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Format Phone Number

Is there a way to parse the contents of a textbox into a phone number format?
Actually I would like to save the input as a number but display it as a
phone number in the typical US format (000) 000-0000.

Thanx in advance,
Poe
Nov 16 '05 #1
6 29203
I can only suggest that you iterate through the string entered and check each
character to see if it's either a ' ( ' , a ' - ' or a ' ) ', or a digit.
If each is in the correct position in the array, fine, otherwise send a
MessageBox to the screen advising to enter correct format.

I would also suggest that you wait for another reply as I have only been
studying programming for a few months.

"Poewood" wrote:
Is there a way to parse the contents of a textbox into a phone number format?
Actually I would like to save the input as a number but display it as a
phone number in the typical US format (000) 000-0000.

Thanx in advance,
Poe

Nov 16 '05 #2
Poewood wrote:
Is there a way to parse the contents of a textbox into a phone number format?
Actually I would like to save the input as a number but display it as a
phone number in the typical US format (000) 000-0000.

Thanx in advance,
Poe


int iPhone = 7065551212;
string strPhone = string.Format("{0:(###) ###-####}", iPhone);
--
Tom Porterfield
MS-MVP Windows
http://support.telop.org

Please post all follow-ups to the newsgroup only.
Nov 16 '05 #3
Tom Porterfield wrote:

Poewood wrote:
Is there a way to parse the contents of a textbox into a phone number format?
Actually I would like to save the input as a number but display it as a
phone number in the typical US format (000) 000-0000.

Thanx in advance,
Poe


int iPhone = 7065551212;
string strPhone = string.Format("{0:(###) ###-####}", iPhone);


or:

iPhone.ToString("(###) ###-####");
Nov 16 '05 #4
If there is any remote possibility this will be used internationally, be
advised that there is not much logic to phone number lengths and formats
outside the US. The length of a phone number can be different between towns
even in the same country

"Poewood" <Po*****@discussions.microsoft.com> wrote in message
news:37**********************************@microsof t.com...
Is there a way to parse the contents of a textbox into a phone number
format?
Actually I would like to save the input as a number but display it as a
phone number in the typical US format (000) 000-0000.

Thanx in advance,
Poe

Nov 16 '05 #5
Drebin wrote:
If there is any remote possibility this will be used internationally, be
advised that there is not much logic to phone number lengths and formats
outside the US. The length of a phone number can be different between towns
even in the same country

"Poewood" <Po*****@discussions.microsoft.com> wrote in message
news:37**********************************@microsof t.com...
Is there a way to parse the contents of a textbox into a phone number
format?
Actually I would like to save the input as a number but display it as a
phone number in the typical US format (000) 000-0000.

Thanx in advance,
Poe


Most places have a standard phone number format.
Aus (00) 0000 0000
If someone really wanted to be clever, they could allow the user to set
the desired phone format using a system config class or such.

JB
:)
Nov 16 '05 #6
Hi Guys,

For some European countries, e.g. Sweden, this would not be applicable.
In Sweden the area code can be 1-3 digits long excluding the starting 0
if you call from within Sweden. Then the actual phone number can be 5-8
digits long, depending on which area code you have dialed.

BR
/Joakim

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: joemono | last post by:
Hello everyone! First, I appologize if this posting isn't proper "netiquette" for this group. I've been working with perl for almost 2 years now. However, my regular expression knowledge is...
5
by: Kamaluokeakua | last post by:
I have to write an application that deals with clients in multiple countries. The addresses, phone numbers, country id and currency information has to be stored into a database that allows for the...
3
by: Mike | last post by:
I need to update a table with a phone number and have the phone number like (800)555-1212 how can I put ( ) around the area code in the update process?
6
by: KFactor | last post by:
I would like to convert a 10-digit string phone number (1234567890) to say (xxx) xxx-xxxx. Is there a function for this or should I write the code to piece together one character at a time? Any...
4
by: Brian Henry | last post by:
I have phone numbers like this in a data table 123-435-1234 1231231234 432.234.2321 they all have different formatting, what I want to do is get them all formatted like this (123) 123-1234
1
by: womblesjc | last post by:
I have a data bound Details View control in asp.net 2.0 that formats a phone number. The 'Default Mode' for the control is set to Edit. The phone number field is a template field and I can...
10
by: JackM | last post by:
I'm still working on validating the phone numbers that are entered on a form but have come across a problem I don't understand how to fix. I can handle most instances when it's in regular US...
2
by: jeswin12 | last post by:
I used the following script to auto format the phone number field in my form. http://javascript.internet.com/forms/format-phone-number.html The problem with this code is im able to set the...
4
by: luke noob | last post by:
This is my HTML... <head> <script type="text/javascript" src="js/jquery-1.2.6.pack.js"></script> <script type="text/javascript" src="js/script.js"></script> </head> <body>
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.