Why during the conversion is not caught an exception, but a system error is caused?

int n = 0; int alfa = 255; try { n = StrToInt(Edit1->Text); } catch(EConvertError &e){}; try { alfa = StrToFloat(Edit2->Text); } catch(EConvertError &e){}; 
  • And where is the trow that raises the exception? - BuilderC
  • 2
    No need to throw. StrToInt and so perfectly everything generates. Is the code accidentally running from under the debugger? - KoVadim
  • one
    Try to run without a debugger (directly from the folder for example). - Yaroslav Schubert
  • Thank you, everything starts without a debugger! - stream2006 2:46 pm

2 answers 2

  if(!TryStrToInt(...)) Application->MessageBoxA(....) 

    This is how it works:

      bool Err = false; double dValue; AnsiString s = "5.3"; try { dValue = s.ToDouble(); } catch(EConvertError&) { Err = true; } if(Err) { DecimalPoint = ','; OppositePoint = '.'; } else { DecimalPoint = '.'; OppositePoint = ','; } 
    • It is very useful to recommend changing the system separator. Especially if the code still works, let's do it with Excel. Then in the output there may be separators at odds. But I’m also not sure if AnsiString has a toString method in C ++ builder. Do you program a lot in C ++ / CLI? - KoVadim
    • This is from a real C ++ Builder program. I do not always have the right to change the separators on someone else's machine. And these transformations are only for domestic consumption. That the person and did not notice, with what decimal dividers works. How used. - Evgeny Nekrasov
    • These changes will come out sideways if you immerse for example Excel / Word. - KoVadim