7
Answers

converting from integer to double

Fadugba Jeremiah

Fadugba Jeremiah

11y
1.5k
1
please i have three textbox and  datagridview. I have successfully sum up two columns and insert the result into their respective textbox but i now want to divide the two textbox which are integer and insert the result into the third textbox which should be in decimal
here is my code the problem is highlighted in blue.

private void calculate_Click(object sender, EventArgs e)
        {
            int sumunt = 0;
            for (int i = 0; i < dataGridView1.Rows.Count; ++i)
            {
                sumunt += Convert.ToInt32(dataGridView1.Rows[i].Cells["crsunt"].Value);
            }
           totcrsunt.Text = sumunt.ToString();


           int sumgp = 0;
           for (int i = 0; i < dataGridView1.Rows.Count; ++i)
           {
               sumgp += Convert.ToInt32(dataGridView1.Rows[i].Cells["crsgp"].Value);
           }
           totcrsgp.Text = sumgp.ToString();

           int grpnt = Convert.ToInt32(totcrsgp);
           int unit = Convert.ToInt32(totcrsunt);
           int cgpa = grpnt % unit;
            mycgpa.Text = cgpa.ToString();
Answers (7)