By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,327 Members | 849 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,327 IT Pros & Developers. It's quick & easy.

How to convert correctly

P: n/a
Hello group,

I have a little problem and I don't know how to solve it. I use Textbox to
let my user type the price of their products. The Textbox only accept number
and the decimal separator. When they confirm the price I do a
Convert.ToDecimal to store the value in the database. The problem is when
they enter a really big number in the textbox. The convert function faile.
My questions are:
What is the best thing to do in that kind of situation? Is the Try Catch is
the only way to solve this kind of error? I don't what to use the Try Catch
because it slow down the program.

Thank you very much for your help :-)
Marc R.
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Marc Robitaille" <ma*************@ars-solutions.caa> wrote in
news:uz**************@TK2MSFTNGP14.phx.gbl:
What is the best thing to do in that kind of situation? Is the Try
Catch is the only way to solve this kind of error? I don't what to use
the Try Catch because it slow down the program.


I would use a try/catch to catch a conversion error.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 21 '05 #2

P: n/a

"Marc Robitaille" <ma*************@ars-solutions.caa> wrote in message
news:uz**************@TK2MSFTNGP14.phx.gbl...
Hello group,

I have a little problem and I don't know how to solve it. I use Textbox to
let my user type the price of their products. The Textbox only accept
number and the decimal separator. When they confirm the price I do a
Convert.ToDecimal to store the value in the database. The problem is when
they enter a really big number in the textbox. The convert function faile.
My questions are:
What is the best thing to do in that kind of situation? Is the Try Catch
is the only way to solve this kind of error? I don't what to use the Try
Catch because it slow down the program.

Thank you very much for your help :-)
Marc R.

It shouldnt slow it down too much if they dont type in unreasonably large
numbers.

use Try/Catch
Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.