469,647 Members | 1,803 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,647 developers. It's quick & easy.

Phone Format (770) 123-1234

Hi,

How do I apply phone format in a string field? for example (770) 123-1234.
Please let me know.

Thanks.

Eddy
Nov 17 '05 #1
3 12342
Hi Eddy,

If you are validating input, you can use a RegularExpressionValidator and
select U.S. Phone Number in the Regular Expression Editor (by clicking the
elipses in the ValidationExpression box in the RegularExpressionValidator's
Properties window).
--
Ray Dixon - Microsoft MVP
ra*@NOSPAM.greeble.com
(remove NOSPAM. from my e-mail address for a direct reply)
"Eddy Soeparmin" <es********@clientprofiles.com> wrote in message
news:uC**************@TK2MSFTNGP11.phx.gbl...
Hi,

How do I apply phone format in a string field? for example (770) 123-1234.
Please let me know.

Thanks.

Eddy

Nov 17 '05 #2
you'd have to use javascript to do this
"Eddy Soeparmin" <es********@clientprofiles.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi Ray,

No, this is not at validation. It's for display. For example, I just
retrieved data from database and would like to display phone number in (123) 123-1234 format within a datagrid.

Eddy

"Ray Dixon [MVP]" <ra*@NOSPAM.greeble.com> wrote in message
news:uu**************@TK2MSFTNGP12.phx.gbl...
Hi Eddy,

If you are validating input, you can use a RegularExpressionValidator and
select U.S. Phone Number in the Regular Expression Editor (by clicking the elipses in the ValidationExpression box in the

RegularExpressionValidator's
Properties window).
--
Ray Dixon - Microsoft MVP
ra*@NOSPAM.greeble.com
(remove NOSPAM. from my e-mail address for a direct reply)
"Eddy Soeparmin" <es********@clientprofiles.com> wrote in message
news:uC**************@TK2MSFTNGP11.phx.gbl...
Hi,

How do I apply phone format in a string field? for example (770)

123-1234. Please let me know.

Thanks.

Eddy



Nov 17 '05 #3
Function FormatPhoneNumbers(ByVal strInputPhoneNumber As String) As String

'Strip off the ( , ) and -

Dim strPhoneNumber As String

strInputPhoneNumber = strInputPhoneNumber.Replace(" ", "")

strInputPhoneNumber = strInputPhoneNumber.Replace("(", "")

strInputPhoneNumber = strInputPhoneNumber.Replace(")", "")

strInputPhoneNumber = strInputPhoneNumber.Replace("-", "")

'Now format it

If strInputPhoneNumber.Length >= 3 Then

strPhoneNumber = "(" & strInputPhoneNumber.Substring(0, 3) & ") "

If strInputPhoneNumber.Length < 6 Then

strPhoneNumber = strPhoneNumber & strInputPhoneNumber.Substring(3,
strInputPhoneNumber.Length - 3)

Else

strPhoneNumber = strPhoneNumber & strInputPhoneNumber.Substring(3,
3) & "-" & strInputPhoneNumber.Substring(6)

End If

End If

Return strPhoneNumber

End Function
--
Swanand Mokashi
Microsoft Certified Professional
http://www.swanandmokashi.com/
Home of the Stock Quotes, Quote of the day and Horoscope web services
"Eddy Soeparmin" <es********@clientprofiles.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi Ray,

No, this is not at validation. It's for display. For example, I just
retrieved data from database and would like to display phone number in (123) 123-1234 format within a datagrid.

Eddy

"Ray Dixon [MVP]" <ra*@NOSPAM.greeble.com> wrote in message
news:uu**************@TK2MSFTNGP12.phx.gbl...
Hi Eddy,

If you are validating input, you can use a RegularExpressionValidator and
select U.S. Phone Number in the Regular Expression Editor (by clicking the elipses in the ValidationExpression box in the

RegularExpressionValidator's
Properties window).
--
Ray Dixon - Microsoft MVP
ra*@NOSPAM.greeble.com
(remove NOSPAM. from my e-mail address for a direct reply)
"Eddy Soeparmin" <es********@clientprofiles.com> wrote in message
news:uC**************@TK2MSFTNGP11.phx.gbl...
Hi,

How do I apply phone format in a string field? for example (770)

123-1234. Please let me know.

Thanks.

Eddy



Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by joemono | last post: by
4 posts views Thread by Brian Henry | last post: by
1 post views Thread by MuZZy | last post: by
7 posts views Thread by laredotornado | last post: by
2 posts views Thread by David C | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.