也算初学C#,用VS2012写了书上一个windows窗体应用程序,可是窗体计算器运行时无法显示。
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Da...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
double corpus_amount, interest_rate, interest_amount, income_amount;
int deposit_years;
string str;
try
{
corpus_amount = double.Parse(corpus_textBox.Text);
deposit_years = Int32.Parse(years_textBox.Text);
interest_rate = double.Parse(interest_textBox.Text) / 100;
}
catch
{
MessageBox.Show("输入非数字!");
return;
}
income_amount = corpus_amount * Math.Pow((1 + interest_rate), deposit_years);
interest_amount = income_amount - corpus_amount;
str = string.Format("{0,3:d} {1,10:c} {2,8:c} {3,15:c}", deposit_years, corpus_amount, interest_amount, income_amount);
result_listBox.Items.Add(str);
}
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
} 展开
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
double corpus_amount, interest_rate, interest_amount, income_amount;
int deposit_years;
string str;
try
{
corpus_amount = double.Parse(corpus_textBox.Text);
deposit_years = Int32.Parse(years_textBox.Text);
interest_rate = double.Parse(interest_textBox.Text) / 100;
}
catch
{
MessageBox.Show("输入非数字!");
return;
}
income_amount = corpus_amount * Math.Pow((1 + interest_rate), deposit_years);
interest_amount = income_amount - corpus_amount;
str = string.Format("{0,3:d} {1,10:c} {2,8:c} {3,15:c}", deposit_years, corpus_amount, interest_amount, income_amount);
result_listBox.Items.Add(str);
}
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询