-1

so I'm trying to do some calculation and textbox66 here should be the result, but it ended up showing "input string was not in correct format". how can I fixed this? thankyou

else if (2.8 < fsF & fsF <= 3)
{
    textBox66.Text = ((((0.8 * fF + 0.7) - (0.8 * fF + 0.67)) * (fsF - 2.8) / 0.2) +
        (0.8 * fF + 0.67)).ToString();
}

var w0 = Convert.ToDecimal(float.Parse(textBox66.Text));
var wdesain = Convert.ToDouble(w0 * F * web00 / 1000);`
Olivier Jacot-Descombes
  • 104,806
  • 13
  • 138
  • 188

1 Answers1

0

It makes no sense to convert a string to a float, just convert it to a decimal afterwards.

decimal w0 = Decimal.Parse(textBox66.Text);

Also, the numbers like 0.8 are of type double. 0.8m is decimal. 0.8f is float. Of what type are the variables fsF, fF? Be more consistent with the numeric types. Intermixing all these type makes no sense.

We see only an else if setting the value of the textbox. What happens in the other cases? If the textbox is empty (textBox66.Text == ""), then the conversion will fail.

Olivier Jacot-Descombes
  • 104,806
  • 13
  • 138
  • 188