Kaung Htet Kyaw

Kaung Htet Kyaw

  • NA
  • 61
  • 5.9k

Finding the solution of this exception

Jan 3 2020 6:21 AM
Hi everyone, I am trying to solve this exception. Actually, I am trying to find the value of efficiency of the machine using the computer program. At first, this is suitable for me to calculate the Mechanical advantage and velocity ratio. But I got this exception when I calculate the efficiency of the machine using the results of the MA and VR and I can't get to continue over this problem. I will be pleased if someone solves my problem.
 
  public partial class frmMechanicalAdvantage_VelocityRatioandEfficiencyCalculation : Form
    {
        public frmMechanicalAdvantage_VelocityRatioandEfficiencyCalculation()
        {
            InitializeComponent();
        }

        private void btnCalculateMA_Click(object sender, EventArgs e)
        {
            try
            {
                float W, P, MA;
                W = Convert.ToInt32(txtW.Text);
                P = Convert.ToInt32(txtP.Text);
                MA = W / P;
                lblMA.Text = Convert.ToString(MA);
                lblma2.Text = Convert.ToString(MA);
               
            }
            catch (Exception)
            {
                MessageBox.Show("Please Enter Numbers only", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }

        private void btnCalculateVR_Click(object sender, EventArgs e)
        {
            try
            {
                float DE, DL, VR;
                DE = Convert.ToInt32(txtDE.Text);
                DL = Convert.ToInt32(txtDL.Text);
                VR = DE / DL;
                lblVR.Text = VR.ToString();
                lblvr2.Text = VR.ToString();
            }
            catch (Exception)
            {
                MessageBox.Show("Please Enter Numbers only", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        private void btnCalculateEFF_Click(object sender, EventArgs e)
        {
            //try
            //{
            double ma, vr;
            double eff;
            ma = Convert.ToInt32(lblMA.Text);
            vr = Convert.ToInt32(lblVR.Text);
            eff = Convert.ToDouble((ma / vr) * 100);
            lblEfficiency.Text = Convert.ToInt32(eff) + " %";
            if (lblma2.Text == "")
            {
                MessageBox.Show("Please Calculate Mechanical Advantage First", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (lblvr2.Text == "")
            {
                MessageBox.Show("Please Calculate Velocity Ratio First", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            //}
            //catch (FormatException FE)
            //{
            //    MessageBox.Show(FE.Message);
            //}
        }


        private void btnClose_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}

Answers (5)