2
Answers

Integer in a textbox becomes zero

amber

amber

11y
1.2k
1
Hi,

In my application i have one button named "Score" and few textboxes and comboboxes for participating in calculating a score.  After entering and selecting marks in textboxes n combos, when i click on score button then numbers in few few T.B N COMBO becomes zero nt all of 'em but few..

Can anyone tell me what could b the reason for that, what common mistakes i mite b making?? i have their datatyps many times in a code n a database as well, m using ms access 2007 for maintaining my data.
method for score:

public int score()
        {
            inctotal.Text = i.ToString();
            i = Convert.ToInt32(Console.ReadLine());
           
            if (i <= 15000)
            {
                scor1 = Convert.ToInt32(5);
            }
            else if (i >= 15001 && i <= 25000)
            {
                scor1 = Convert.ToInt32(4);
            }
            else if (i >= 25001 && i <= 35000)
            {
                scor1 = Convert.ToInt32(3);
            }
            else if (i >= 35001 && i <= 45000)
            {
                scor1 = Convert.ToInt32(2);
            }
            else if (i >= 45001 || i >= 55000)
            {
                scor1 = Convert.ToInt32(1);
            }
            textBoxinc.Text = scor1.ToString();
            

            if (radioNoearning.Checked == true)
            {
                scor2 = Convert.ToInt32(5);
            }
            else if(radioEarning.Checked == true)
            {
                scor2 = Convert.ToInt32(4);
            }
            textBoxearn.Text = scor2.ToString();

            comboBox4.Text = j.ToString();
            j = Convert.ToInt16(Console.ReadLine());

            if (j >= 5)
            {
                scor3 = Convert.ToInt32(5);
            }
            else if (j == 4)
            {
                scor3 = Convert.ToInt32(4);
            }
            else if (j == 3)
            {
                scor3 = Convert.ToInt32(3);
            }
            else if (j == 2)
            {
                scor3 = Convert.ToInt32(2);
            }
            else if (j == 1)
            {
                scor3 = Convert.ToInt32(1);
            }
            textBoxdepend.Text = scor3.ToString();
           .........

on btn_score:

score();
 MessageBox.Show("The Score is: " + scor); 

Answers (2)