Example #1
0
 /// <summary>
 /// If buttonFromDecimal is clicked, convert the text in textBoxDecimalVal
 /// into a new value of the specified base in textBoxNewBase.
 /// </summary>
 private void buttonFromDecimal_Click(object sender, EventArgs e)
 {
     try
     {
         this.textBoxNewBase.Text =
             BaseConverter.FromDecimal(textBoxDecimalVal.Text,
                                       (int)numericUpDownBase.Value,
                                       (int)numericUpDownDigits.Value);
     }
     catch (OverflowException)
     {
         MessageBox.Show("Decimal input is too large for an integer.");
     }
     catch (Exception)
     {
         MessageBox.Show("Failed to convert decimal input to an integer.");
     }
 }
Example #2
0
        }//end

        /// <summary>
        /// Button for Decimal > Base conversion
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            //textBox2.Text = BaseConverter.ResultsPlace((int)numericUpDown2.Value - BaseConverter.FromDecimal(int.Parse(textBox1.Text), (int)numericUpDown1.Value).Length);
            if (textBox1.Text == string.Empty)
            {
                MessageBox.Show("Please consider inputting a number before pressing that button.");
            }
            else
            {
                textBox2.Text = BaseConverter.ResultsPlace((int)numericUpDown2.Value - BaseConverter.FromDecimal(int.Parse(textBox1.Text), (int)numericUpDown1.Value).Length, (int)numericUpDown1.Value) + BaseConverter.FromDecimal(int.Parse(textBox1.Text), (int)numericUpDown1.Value);
            }
            textBox1.ForeColor = Color.Blue;
            textBox2.ForeColor = Color.Red;
        }//end