I am doing a new integer box and I want it to accept only integer numbers and the exponential E. I know that do the Exponential E you have to do Math.Exp(x) but I can't seem to find the right place to put it. Could someone help me please?
namespace IntegerBox
{
public partial class IntBox : TextBox
{
private double intNum;
public double IntNum
{
get { return intNum; }
set { intNum = value; }
}
public IntBox()
{ // set initial values to prperty Text, Event handlers properties TextChanged, Leave
this.Text = "0";
this.TextChanged += new EventHandler(IntBox_TextChanged);
this.Leave += new EventHandler(IntBox_Leave);
this.Math.Exp();
InitializeComponent();
}
protected void IntBox_TextChanged(object sender, EventArgs e)
{
try
{
IntNum = Convert.ToDouble(this.Text);
Math.Exp(intNum);
}
catch (FormatException)
{
MessageBox.Show("Other than Integer number entered",
"Your error was",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
protected void IntBox_Leave(object sender, EventArgs e)
{
intNum = Convert.ToDouble(this.Text);
Math.Exp(intNum);
//intNum = Math.Exp(this.Text);
}
protected override void OnPaint(PaintEventArgs pe)
{
base.OnPaint(pe);
}
private void IntBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyValue == 13)
{
intNum = Convert.ToDouble(this.Text);
Math.Exp(intNum);
// intNum = Math.Exp(this.Text);
}
}
}
}