"it's not a valid floating point value"

TommyDue

Grünschnabel
Wie kann ich bei keiner Eingabe in das Textfeld verhindern, dass das Programm abstürtz?

void __fastcall TForm1::Button1Click(TObject *Sender)
{
long double r;
double const PI = 3.1415926;

r = StrToFloat (Edit1->Text);
Edit2->Text = FloatToStr (r*r*PI);
}

Danke
 
Mit nem Try-Catch:

Code:
try
{
long double r;
double const PI = 3.1415926;

r = StrToFloat (Edit1->Text);
Edit2->Text = FloatToStr (r*r*PI);
}
catch(Exception &ex)
{
 MessageBox(NULL,ex.Message.c_str(),"Problem:",MB_OK);
}
 
Zurück