I have a problem with the following code.
bool TextBox2INT = true;
bool TextBox1INT = true;
int outputValue = 0;
int ButtonFind;
int TextBox1INT2 = Convert.ToInt32(TextBox1INT);
int TextBox2INT2 = Convert.ToInt32(TextBox2INT);
TextBox2INT = int.TryParse(textBox2.Text, out outputValue);
TextBox1INT = int.TryParse(textBox1.Text, out outputValue);
ButtonFind = (int)Math.Round((double)(TextBoxt1INT2 * 0.0333m * TextBox2INT2) + (double)(TextBox1INT2));
textBoxFind.Text = ButtonFind.ToString();
The problem is that the code works perfectly fine but when im debugging the answer in textBoxFind.Text is always 1.
You’re calling
Convert.ToInt32(bool)which will only ever give 0 or 1.I think you meant:
You should also take action if
int.TryParsereturns false – for example, telling the user to enter a valid number, instead of performing the calculation anyway. I’d also change your variable names, so you’d have something like: