Thursday, 10 May 2012

CALCULATION IN TEXTBOX USING Convert.ToInt32 and int.parse

                                USING Convert.ToInt32

private void button1_Click(object sender, EventArgs e)
{
int value1 = Convert.ToInt32(this.textBox1.Text);

int value2 = Convert.ToInt32(this.textBox2.Text);

int value3 = Convert.ToInt32(this.textBox3.Text);

int value4 = (value2-value1) * value3;

 this.textBox4.Text = value4.ToString();

 }
USING  int.Parse
private void button1_Click(object sender, EventArgs e)
{

int value1 =(textBox1.Text);

int value2 = int.Parse(textBox2.Text);

int value3 = int.Parse(label1.Text);

intvalue4 = (value2-value1) * value3;

textBox4.Text = value4.ToString();
}

No comments:

Post a Comment

back to top