Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

formating a phonenumber

Status
Not open for further replies.

sthmpsn1

MIS
Sep 26, 2001
456
US
I am trying to format a number in my database as a phone number and don't know if I am doing it right. I have a variable that I have set up as an integer. Then I take that variable and do a tostring command like this

fax1.ToString("(###)-###-####")

I am getting this error though

Arithmetic operation resulted in an overflow.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.OverflowException: Arithmetic operation resulted in an overflow.

Source Error:


Can anyone help me on this?
 
st: Have a few options to look over but try first changing your variable from integer to Long -- in vba in Access the top end for an integer is 32,000+, and an overflow will result beyond that (change over to Long Integer). Just a thought - I have some formatting statements I could share also.
 
st: Just checked it. When you declare your int as Long, it works fine. Tested it with the following:

Dim intNum As Long = 8045678987
mytext.text = Format(intNum, "(###)-###-####")

...gave the correct format in the textbox.
 
thank you for showing me that, I also figured out that it will work with a double as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top