Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8597939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:02:16+00:00 2026-06-12T01:02:16+00:00

Possible Duplicate: C++ Windows Forms application unhandled exception error when textbox empty I’m building

  • 0

Possible Duplicate:
C++ Windows Forms application unhandled exception error when textbox empty

I’m building a temperature conversion application in Visual Studio for a C++ course. It’s a Windows Forms application and the code that I’ve written is below. There’s other code to of course, but I’m not sure you need it to help me.

My problem is, when I run the application if I don’t have anything entered into either the txtFahrenheit or txtCelsius2 textboxes I get the following error:

“An unhandled exception of type ‘System.FormatException’ occurred in mscorlib.dll”

The application only works right now when a number is entered into both of the textboxes.

private: System::Void btnFtoC_Click(System::Object^  sender, System::EventArgs^  e) 
             {               
                // Convert the input in the Fahrenheit textbox to a double datatype named fahrenheit for manipulation
                double fahrenheit = Convert::ToDouble(txtFahrenheit->Text);
                // Set the result string to F * (5/9) -32
                double result = fahrenheit * .5556 - 32;
                // Set the Celsius text box to display the result string
                txtCelsius->Text = result.ToString();
             }

private: System::Void btnCtoF_Click(System::Object^  sender, System::EventArgs^  e) 
             {
                // Convert the input in the Celsius textbox to a double datatype name celsius for manipulation
                double celsius = Convert::ToDouble(txtCelsius2->Text);
                // Set the result2 string to C * (9/5) + 32
                double result2 = celsius * 1.8 + 32;
                // Set the Fahrenheit text box to display the result2 string
                txtFahrenheit2->Text = result2.ToString();
             }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T01:02:18+00:00Added an answer on June 12, 2026 at 1:02 am

    You can’t convert an empty string into a Double.

    You should use an if statement to do something else instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Issue while saving image using savefiledialog I use windows forms in C#.
Possible Duplicate: Writing a Windows system tray application with .NET I want to develop
Possible Duplicate: C++ std::string conversion problem on Windows How to convert std::string to LPCSTR?
Possible Duplicate: Open a URL from Windows Forms Hello! I have a C# desktop
Possible Duplicate: Standard Windows menu bars in Windows Forms I am using windows forms
Possible Duplicate: .NET windows application, can it be compressed into a single .exe? I
Possible Duplicate: .NET windows application, can it be compressed into a single .exe? To
Possible Duplicate: Windows Phone 7 close application How do I programmatically close a WP7
Possible Duplicate: .NET windows application, can it be compressed into a single .exe? I
Possible Duplicate: Windows Phone 7 close application I have an app which needs quiting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.