【发布时间】:2016-03-30 23:58:52
【问题描述】:
我正在做一个新的整数框,我希望它只接受整数和指数 E。我知道做指数 E 你必须做 Math.Exp(x) 但我似乎找不到放置它的正确位置。有人可以帮帮我吗?
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);
}
}
}
}
【问题讨论】:
-
Math.Exp返回新值。你对这个值什么都不做 -
那么我应该怎么做才能让它接受指数 e?因为我到处找,什么都找不到
-
检查 MSDN 以获取
Math.Exp()的返回类型,将其分配给变量并显示在您的控件上。 -
无论如何你想对计算结果做什么?在某处显示它?
-
是的,然后我做了一个表格,只让用户输入整数和指数 e
标签: c# exponential