Well I started my developer edu just a month ago. We prob learn this also
Printable View
int aantaltextBox = Convert.ToInt32(textBox.Text);
int limiet = Convert.ToInt32(textBox1.Text);
int aantallabel = Convert.ToInt32(label.Content=0);
while (aantallabel < limiet)
{
label.Content = aantallabel + aantaltextBox;
}
i think the problem with this code is that every time you click this button, it resets label to 0. so everytime you click the button, it does label.Content = numTextbox (user input) + numLabel (which is always 0). you only want the label to output 0 once, thats when the program starts.
label.Content = 0;
private void method1{
int numTextbox = Int32.Parse(numBox.Text);
int limit = Int32.Parse(limitBox.Text);
int numLabel = int32.Parse(label.Text);
if (numTextbox <= limit) label.Content = numTextbox + numLabel;
}
Ye i know, had already tried it before but it says: "The name 'label.Content' does not exist in the current context" and "The name 'label' does not exist in the current context. And i get a error by 'label.Text' i changed it to 'label.Content' but then i get a different error: "Argument 1: cannot convert from 'object' to 'string' "
http://i.imgur.com/WWWEwzr.png
- - - Updated - - -
Hmm even when it works, i still need 1 button though.. don't know how i could put that all into 1 button.
You really think i just gonna post some homework in a GAMEFORUM because you think im lazy? I've looked days/hours into this problem without luck. And like i said it a small problem of my hw(see example) i never said do the whole shit because i know the rest. What you did was using 2 buttons to solve(still had errors) it go ahead try to find it while using only 1 then talk. Like i said if you dont want to help i inderstand that but i dont need this shit talking from someone who thinks he all knows whats going on.
Just to confirm. It works with two buttons, yes?
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! :D 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");
}
}