Parse / textBox.Text question

  • Thread starter Thread starter Patrick De Ridder
  • Start date Start date
P

Patrick De Ridder

When I code

Double.Parse(textBox1.Text)

I get an error

How can I convert a text box entry to a numeric?

Please give a code example, if you know the answer.
 
Hi,
You should only receive an error when the Text property
is null, or is not a number, for example "1" will parse
correctly, "" or "Not a number" will not.
I would suggest that you wrap your Double.Parse statement
in try/catch and check for an error that states something
like 'the input string was an incorrect format', etc.

HTH,

Martin
 
Back
Top