第1个回答 推荐于2018-03-28
private void button1_Click(object sender, EventArgs e)
{
double area;
if (textBox1.Text = "")
{
MessageBox.Show("请输入圆的半径");
}
else
{
try
{
double r = Convert.ToDouble(textBox1.Text);
}
catch
{
MessageBox.Show("请输入一个double型变量作为圆的半径");
}
area = 3.1415926 * r * r;
}
textBox2.Text = area.ToString();
}本回答被网友采纳
第2个回答 2011-12-21
private void button1_Click(object sender, EventArgs e)
{
double area;
if (textBox1.Text = "")
{
MessageBox.Show("请输入圆的半径");
}
else
{
try
{
double r = Convert.ToDouble(textBox1.Text);
}
catch
{
MessageBox.Show("请输入一个double型变量作为圆的半径");
}
area = 3.1415926 * r * r;
}
textBox2.Text = area.ToString();
}
这是button1单击实现计算面积的代码,其他控件起什么名字 放什么位置自己怎么顺眼怎么来