Originally Posted by
Paul
Well this worked for me.
Code:
public void button1_Click(object sender, EventArgs e)
{
int firstbox = Int32.Parse( textBox1.Text ); //here you input first value
int firstvalue = Int32.Parse( textBox1.Text ); // this is to store the first value you write in textbox
int secondbox = Int32.Parse(textBox1.Text); //second input!
int secondvalue = Int32.Parse(textBox1.Text); //this is to store the second value that you input after buttonclick
int result = firstbox + secondbox; //the sum
int limitbox = Int32.Parse(textBox2.Text); //limit!
textBox1.Text = ""; //this is so that the textbox clears after the click
if (result <= limitbox)
{ //if you only write < and the MAX is 20, it will give you Invalid because 20 is not less than 20
textBox1.Text = result.ToString();
}
else
{
MessageBox.Show("Invalid input");
}
}
YESSS it worked! i changed it a bit. Thank you very much Paul and yes you too yung and the other people for replying and trying to help /request lock
Code:
private void button_Click(object sender, RoutedEventArgs e)
{
int firstbox = Int32.Parse(textBox1.Text); //here you input first value
int secondbox = Convert.ToInt32(label.Content); //second input!
int result = firstbox + secondbox; //the sum
int limitbox = Int32.Parse(textBox2.Text); //limit!
textBox1.Text = ""; //this is so that the textbox clears after the click
if (result <= limitbox)
{ //if you only write < and the MAX is 20, it will give you Invalid because 20 is not less than 20
label.Content = result.ToString();
}
else
{
MessageBox.Show("Invalid input");
}
}