Mike abban

Mike abban

  • NA
  • 10
  • 25.2k

clearing a text box for calculation

Jun 15 2012 11:19 AM

i have a form that calculate student marks and grade. there is one text box on the form which am finding it difficult reset or clear the text in that textbox. i just double clicked the text box put this code behind it. it is working alright but i cant use

this.txtFcs_exams.Text = "";

to clear the textbox. please help me out. when clearing the screen i get an error message "input string was not in a correct format"

private void txtFcs_exams_TextChanged(object sender, EventArgs e)
        {

            try
            {


                    double classworkFcs, iaFcs, examsFcs, totalsFcs;

                    classworkFcs = Convert.ToDouble(txtFcs_classwork.Text);
                    iaFcs = Convert.ToDouble(txtFcs_ia.Text);
                    examsFcs = Convert.ToDouble(txtFcs_exams.Text);

                    totalsFcs = classworkFcs + iaFcs + examsFcs;
                    txtFcs_totals.Text = totalsFcs.ToString();

                    if (totalsFcs >= 75)
                    {
                        txtFcs_grading.Text = "   A";
                    }
                    else if (totalsFcs >= 70)
                    {
                        txtFcs_grading.Text = "   B";
                    }
                    else if (totalsFcs >= 65)
                    {
                        txtFcs_grading.Text = "   C";
                    }
                    else if (totalsFcs >= 55)
                    {
                        txtFcs_grading.Text = "   D";
                    }
                    else if (totalsFcs >= 45)
                    {
                        txtFcs_grading.Text = "   E";
                    }
                    else
                    {
                        txtFcs_grading.Text = "   F";
                    }

            }
            catch (System.FormatException fmtE)
            {
                MessageBox.Show(fmtE.Message);
            }


        }



Answers (1)