Helllo,
I want to create the simple program, but i don't know how to do one thing:
i have 2 texbox , label and button
in textboxs you type numbers, and the answer appears in label.
And all it should be programmed on button click.
But i need that, if my number is smaller thatn 18 and bigger than 25 then label set text , f.e. " it good" or smtg, and i have these groups:
18.5 < rez < 24.9
25 < rez < 29.9
30 < rez < 39.9
40 < rez < 70
rez is that ansver, and on each other must be different text, that i want to set
but i don't how to do that, i had tried to make 4 if functions but then works just last.
write me how to do that, the code. thanks.

litlle problem
ofa
Alex G.
You need to change your "If" statements to use the AND operator (&&) instead of the OR operator (||).
If you use OR, for any numeric value stored in variable "a", each condition for each "If" statement will be true as OR only requires one of the statements to be true for the entire conditional statement to be true (whereas in AND they both have to be true).
Thus....as "Little Bad" is meant to be displayed if you fall into the last "If" statement you will always get "Little Bad" as the condition is always true.
Have a go of the following and see if it does what you want:
private void btn_all_Click(Object sender, System.EventArgs e)
{
double a = System.Convert.ToDouble(ugis.get_Text().Replace(',', '.'));
double b = System.Convert.ToDouble(svoris.get_Text().Replace(',', '.'));
if (a > 18 && a < 24)
{
double rez = b / (a * a);
lbl_main.set_Text(rez + " Its Good ");
}
if (a > 25 && a < 30)
{
double rez = b / (a * a);
lbl_main.set_Text(rez + " Normal");
}
if (a > 30 && a < 39)
{
double rez = b / (a * a);
lbl_main.set_Text(rez + " Litle Bad");
}
}
You might also consider using something like the if...elseif construct down the line for this function but that can come later.
Hope that helps a bit, but sorry if it doesn't.
haXXa
Your button click event is where you should check the value, and then set your label text. What methods have you created, and how are they called Probably it's best to post your code.
ariana28
I have tried the code on my machine at it will work when the inputs are valid (i.e. the input satisfies the test for one of the If statements)
When the inputs are invalid (i.e. don't meet any condition) then the text in the label will not change.
What values are you putting into your text boxes I am aware that some values will elicit no response such as anything between 24 and 25, 30 and anything greater than or equal to 39.
Hope that helps a bit...I'm pretty sure we're on the right track and together we should be able to knock something up.
bnaveke
Haoder