我该如何在Windowsform中执行代码 [英] How can i do the code in windowsform

查看:75
本文介绍了我该如何在Windowsform中执行代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我该如何执行此代码
就像在文本框中输入基本薪水时一样,我想获得HRD,DA,PF,总薪水,净收入
自动在文本框中告诉我任何一个人



how can i do this code
like when enter Basic salary in textbox i want to get HRD,DA,PF,gross sal,net paid
automatcally these in textboxes tell me any one



static void Main()
{
     float basic;
     float da;
     float hra;
     float tax;
     float pf;
     float gross;
     float net;
     string name = string.Empty;
     Console.Clear();
     Console.Write("\n\n\t ENTER YOUR NAME...:");
     scanf("%s", name);
     Console.Write("\n\t ENTER THE BASIC SALARY...:");
     scanf("%f", basic);
     pf = 0.08 * basic;
     if (basic < 5000)
     {
          da = 0.3 * basic;
          hra = 0.08 * basic;
     }
     else if ((basic >= 5000) && (basic < 10000))
     {
          da = 0.4 * basic;
          hra = 0.1 * basic;
     }
     else
     {
          da = 0.5 * basic;
          hra = 0.2 * basic;
     }
     gross = basic + da + hra;
     net = gross - tax + pf;
     Console.Write("\n\n\t THE GROSS SALARY IS...: {0:f}", gross);
     Console.Write("\n\n\t THE NET SALARY IS...: {0:f}", net);
     Console.ReadKey(true).KeyChar;
}

推荐答案

这是一个控制台应用程序.
控制台应用程序没有文本框或任何其他图形用户界面元素-因为它们不是GUI应用程序.
为了使您的代码可以使用文本框,您需要从头开始使用一个新的WinForms(例如)bsed应用程序.

那是一个全新的世界-它不是始于头,而是事件驱动的.因此,请读一本书,然后开始阅读!
That is a console application.
Console apps do not have textboxes, or any other graphical user interfcae elements - because they are not GUI applications.
In order to get your code working with textboxes, you need to start from scratch with a new, WinForms (for example) bsed application.

And that is a whole new world - it does not run from start to end, it is event driven. So get a book, and start reading!


您将不得不创建Windows Forms应用程序并将当前逻辑复制到新应用程序中,您可能想创建一个单独的方法来计算总费用为了可重复使用和整洁.

You gonna have to create a Windows Forms Application and copy your current logic to the new application, you might wanna create a separate method that calculates the gross for re-usability and neatness.

private float CalculateGross(float basicSalary)
{

//Do your magic in here

}


这篇关于我该如何在Windowsform中执行代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆