473,322 Members | 1,408 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,322 software developers and data experts.

How to convert correctly

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
2 1120
"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

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Lauren Quantrell | last post by:
I have a stored procedure using Convert where the exact same Convert string works in the SELECT portion of the procedure but fails in the WHERE portion. The entire SP is listed below....
3
by: hunterb | last post by:
I have a file which has no BOM and contains mostly single byte chars. There are numerous double byte chars (Japanese) which appear throughout. I need to take the resulting Unicode and store it in a...
1
by: Sam Smith | last post by:
Hi, I wan't a function to take a const char*, a start bit position and number of bits and convert that bit-stream into a primitive of desired type. I.e. something like: char convert(const...
1
by: Swarup | last post by:
I am reading a file (txt, xml, gif, ico, bmp etc) byte by byte and filling it into a byte arry. Now i have to convert it into a string to store it in the database. I use...
13
by: Hako | last post by:
I try this command: >>> import string >>> string.atoi('78',16) 120 this is 120 not 4E. Someone can tell me how to convert a decimal number to hex number? Can print A, B, C,DEF. Thank you.
2
by: Christopher Beltran | last post by:
I am currently trying to replace certain strings, not single characters, with other strings inside a word document which is then sent to a browser as a binary file. Right now, I read in the word...
7
by: MilanB | last post by:
Hello How to convert char to int? Thanks
8
by: csanjith | last post by:
Hi, i have a situaion where i need to convert the characters entered in an text field to upper case using C. The configuration id utf8 environment in which user can enter any character (single ,...
0
by: deloford | last post by:
Hi This is going to be a question for anyone who is an expert in C# Text Encoding. My situation is this: I have a Sybase database which is firing back ISO-8559 encoded strings. I am unable to...
3
by: Sun | last post by:
Hi everyone . I have two files named a.txt and b.txt. I open a.txt with ultraeditor.exe. here is the first row of the file: neu für then I switch to the HEX mode: 00000000h: FF FE 6E 00 65...
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...
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.