C++ Windows Forms application unhandled exception error when textbox empty

前端 未结 1 1582
你的背包
你的背包 2021-01-26 08:16

I\'m building a temperature conversion application in Visual Studio for a C++ course. It\'s a Windows Forms application.

My problem is, when I run the application if I d

相关标签:
1条回答
  • 2021-01-26 08:39

    This will check that the entry in your textbox is convertible to a number.

    double val;
    bool result = System::Double::TryParse(txtFahrenheit->Text,val);
    
    if (result)
    {
        //Converted successfully, you can use val
    }
    else
    {
        //Error
    }    
    
    0 讨论(0)
提交回复
热议问题