如何将此控制台命令更改为Windows窗体应用程序? [英] How do i change this console command to windows form application ?
本文介绍了如何将此控制台命令更改为Windows窗体应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好.我是初学者,我想将此控制台命令转换为Windows窗体应用程序?我加粗了代码
Hello . I am beginner I wanted to convert this console command to windows form application ? i bolded the codes
推荐答案
基本上将标签和文本框控件放置在表单上进行输入,然后在按钮单击事件中验证文本框值是double类型的,如果是,则计算.
Basically place labels and text box controls on the form for input then in a button click event validate the text box values are of type double and if so do your calculations.
using System;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
double balance;
double interestRate;
double targetBalance;
if (double.TryParse(txtbalance.Text, out balance) && double.TryParse(txtAnnualInterest.Text, out interestRate) && double.TryParse(txtLeaveBalance.Text, out targetBalance))
{
// do calculations and show results e.g. in a MessageBox.
}
}
}
}
这篇关于如何将此控制台命令更改为Windows窗体应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文