D Lng

D Lng

  • NA
  • 12
  • 4.8k

Click Button causes App to exit?

Jan 5 2012 2:44 PM
Hi,

I have pasted some code below for two button actions to perform a calculation, the first button action causes the app to exit in the emulator, the second button action works good.
Any ideas please?
Thank you.

Code:
namespace WindowsPhoneApplication11
{
    public partial class PanoramaPage1 : PhoneApplicationPage
    {
        public PanoramaPage1()
        {
            InitializeComponent();
        }
// This button action crashes the app
private void btnGetAvail_Click(object sender, RoutedEventArgs e)
{
var compdown = Convert.ToDouble(tbundown) - Convert.ToDouble(tbplandown);
var shiftact = Convert.ToDouble(tbshift);
var not = shiftact - compdown;
var avail = not / shiftact * 100;
var availr = Math.Round(avail,2);
tbAvail.Text = availr + "%";
}

// This button action works good.
private void btnGetOEE_Click(object sender, RoutedEventArgs e)

{

//var total = Convert.ToDouble(tbYield.Text) * Convert.ToDouble(tbAvailability.Text) * Convert.ToDouble(tbPerformance.Text)* 100;
var total = Convert.ToDouble(tbYield.Text) * Convert.ToDouble(tbAvailability.Text) * Convert.ToDouble(tbPerformance.Text)* 100;
var rounded = Math.Round(total,2);
tbOEE.Text = rounded + "%";
        }
}
}

Answers (7)