Hi,
I'm currently the process of building a calculator designed to calculate the value of any variable provided all other variables are assigned an input value.
So far it's working and I have added a "Clear" button so that all the text box values can be erased should the user wish to start a new calculation with different values.
However, I have been using radioButton's to select the desired output, and when I press the "Clear" button, the radioButton selected for the previous calculation remains where it is.
What I'd like to be able to do it set it so that when the "Clear" button is clicked it will uncheck which ever radioButton was last selected.
Can anyone help me with this? Any advice would be greatly appreciated.
Thank you.
Below is a sample of my current code:
What I have tried:
public partial class Form1 : Form
{
double P1, P2, V1, V2, U1, U2, v1, v2, h1, h2, Q, W, Z, g, PChange, VChange, UChange, vChange, hChange;
public Form1()
{
InitializeComponent();
Z = 0;
P1 = P2 = V1 = V2 = U1 = U2 = v1 = v2 = h1 = h2 = Q = W = Z;
g = 9.81;
}
private void txtBox_P1In_TextChanged(object sender, EventArgs e)
{
double.TryParse(txtBox_P1In.Text, out P1);
}
private void btnClear_Click(object sender, EventArgs e)
{
txtBox_P1In.Clear();
txtBox_P2In.Clear();
txtBox_Vol1In.Clear();
txtBox_Vol2In.Clear();
txtBox_U1In.Clear();
txtBox_U2In.Clear();
txtBox_vel1In.Clear();
txtBox_vel2In.Clear();
txtBox_h1In.Clear();
txtBox_h2In.Clear();
txtBox_QIn.Clear();
txtBox_WIn.Clear();
txtBox_P1Out.Clear();
txtBox_P2Out.Clear();
txtBox_V1Out.Clear();
txtBox_V2Out.Clear();
txtBox_U1Out.Clear();
txtBox_U2Out.Clear();
txtBox_vel1Out.Clear();
txtBox_vel2Out.Clear();
txtBox_h1Out.Clear();
txtBox_h2Out.Clear();
txtBox_QOut.Clear();
txtBox_WOut.Clear();
txtBox_P.Clear();
txtBox_V.Clear();
txtBox_U.Clear();
txtBox_vel.Clear();
txtBox_h.Clear();
txtBox_P1In.Focus();
}
private void CalcButton_Click(object sender, EventArgs e)
{
if (radioButtonP1.Checked == true)
{
P1 = (((P2 * V2) + U2 + ((v2 * v2) / 2) + (g * h2) + W - Q - (g * h1) - ((v1 * v1) / 2) - U1) / V1);
txtBox_P1Out.Text = P1.ToString();
txtBox_P1In.Text = txtBox_P1Out.Text;
}
else
if (radioButtonP1.Checked == false)
{
txtBox_P1Out.Text = null;
}