curzondax
March 8th, 2008, 02:42 PM
I use a Convert::ToDouble(this->TextBox1->Text) to get a double to use later; how can one check if it's valid? e.g. if it's left empty or there's a dot, crash.
|
Click to See Complete Forum and Search --> : How to check if a TextBox number is valid? curzondax March 8th, 2008, 02:42 PM I use a Convert::ToDouble(this->TextBox1->Text) to get a double to use later; how can one check if it's valid? e.g. if it's left empty or there's a dot, crash. cilu March 9th, 2008, 06:46 AM [ redirected thread ] cilu March 9th, 2008, 06:48 AM Well, Convert::ToDouble throws an exception if the conversion fails. You have to try-catch that exception. A better approach is to use Double::TryParse. It does not throw an exception, but returns true or false to indicate an error in the conversion. codeguru.com
Copyright WebMediaBrands Inc., All Rights Reserved. |