C# Exception thrown: 'System.FormatException' in mscorlib.dll

c#
20,937

These could be the possible issues,

the given input may not be in those format which can be converted to double

a = Convert.ToDouble(textBox18.Text);
    z = Convert.ToString(comboBox1.SelectedValue);
    d = Convert.ToDouble(checkBox1.Checked);
    f = Convert.ToDouble(textBox13.Text);
    g = Convert.ToDouble(textBox14.Text);
    t = Convert.ToDouble(textBox19.Text);

or may be it should be something like

    z = Convert.ToString(comboBox1.SelectedValue);
   d = Convert.ToDouble(checkBox1.Checked);
Share:
20,937
Author by

Jason Kats

Updated on July 09, 2022

Comments

  • Jason Kats 3 months

    Exception thrown: System.FormatException in mscorlib.dll

    {"Input string was not in a correct format."}

    I have been at this all day. Please help! Those above were the error messages btw. I am a bit new to C# so I could use a bit more detailed answers (I don't get the jargon so well)

    public partial class Form1 : Form
    {
        double a, b, d, f, g, t;
        string z;
        int c;
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, System.EventArgs e)
        {
        }
        private void button7_Click(object sender, EventArgs e)
        {
            a = Convert.ToDouble(textBox18.Text);
            z = Convert.ToString(comboBox1);
            d = Convert.ToDouble(checkBox1);
            f = Convert.ToDouble(textBox13.Text);
            g = Convert.ToDouble(textBox14.Text);
            t = Convert.ToDouble(textBox19.Text);
            if (z == "a")
            {
                textBox15.Text = Convert.ToString(a * g * d * t);
            }
            else if (z == "b")
            {
                textBox15.Text = Convert.ToString(c);
            }
        }
    
  • Jason Kats almost 6 years
    The given input for all the textBoxes are numbers while the given input for the combobox is letters.
  • Anurag_Soni almost 6 years
    you can find more detail about error in this link :stackoverflow.com/questions/12269254/…