mercredi 18 août 2021

In C#, Depends on some conditions, How can i change the variable according to user input?

I'm newbie here. My problem is :

As an example we have x and y values. x will be 0.06 if an user enters y value between 0 and 0.4. If the user enter 0.5, x value will be 0.14. Also this situation belongs to a selection from combobox. how can I do that ? Here's my attempt.

Many Thanks.

double xx = 0.00;
double yy = Convert.ToDouble(textBox2.Text);
switch (comboBox1.Text)
{
    case "COMBOBOX SELECTION":
      
        if (0 < yy && yy <= 0.4)
        {
            xx = 0.07;
        }
        else if (0.4<yy && yy <= 1)
        {
            xx = 0.14;
        }
        break;

}
textBox1.Text = xx.ToString();

Aucun commentaire:

Enregistrer un commentaire