Beispiel #1
0
        private void btnCalculateWeight_Click(object sender, EventArgs e)
        {
            {
                try
                {
                    //Get input data from textbox
                    Pounds = double.Parse(txtPounds.Text);
                    //Compute results
                    Kilograms = Pounds / 2.2046886218;
                    //Display Results
                    txtKilograms.Text = Kilograms.ToString("N4");

                    //Get input data from textbox
                    Pounds = double.Parse(txtPounds.Text);
                    //Compute results
                    Grams = Pounds * 453.592;
                    //Display Results
                    txtGrams.Text = Grams.ToString("N4");

                    //Clear Distance Fields when Calculating Weight
                    txtFeet.Clear();
                    txtKilometers.Clear();
                    txtMeters.Clear();
                }

                catch
                {
                    MessageBox.Show("Input a number");
                }
            } //Error Message
        }     //End Method
Beispiel #2
0
 public string GetString(bool grams)
 {
     return(grams ? Grams.ToString(GramFormat) : Grains.ToString(GrainFormat));
 }