c第一次_做一个小计算器.docxVIP

  • 9
  • 0
  • 约3.49千字
  • 约 7页
  • 2017-06-07 发布于重庆
  • 举报
c第一次_做一个小计算器

C#程序设计 实验报告 学 号:2123334姓 名:火智英提交日期:2015-04-07成 绩: 东北大学秦皇岛分校 实验一 控件和窗体 实验步骤: 1 点击起始页创建项目或者菜单栏文件—新建?项目,在左边选择visual C#,在右边选择windows窗体应用程序 2.点击菜单 视图,打开“工具箱”,“属性”和“解决方案管理器”三个窗口。 3.在解决方案资源管理器中的解决方案名上点击右键,选择添加—windows窗体,取名Myform 4.添加后会在资源管理器重出现myform.cs,可以双击它打开设计页面 5.在工具箱中拖拽一个button到设计页面中的myform窗体上 6.在属性窗口中修改Text属性为“打开form1” 7.双击这个button,在函数button1_Click中输入如下语句 private void button1_Click(object sender, EventArgs e) { new Form1().Show(this); } 8.双击资源管理器中的programe.cs,修改main函数如下所示 static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Myform()); } 9.点击菜单栏上的按钮运行程序 作业:做一个简单的小计算器,实现整数的加减法,如下图所示 代码如下: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace zuoye1 { public partial class calculator : Form { float num1=-1; int fuhao = 0; public calculator() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { textBox1.Text = button1.Text.ToString (); } private void button2_Click(object sender, EventArgs e) { textBox1.Text += button2.Text.ToString(); } private void button3_Click(object sender, EventArgs e) { textBox1.Text += button3.Text.ToString(); } private void button4_Click(object sender, EventArgs e) { textBox1.Text += button4.Text.ToString(); } private void button5_Click(object sender, EventArgs e) { textBox1.Text += button5.Text.ToString(); } private void button6_Click(object sender, EventArgs e) { textBox1 .Text +=

文档评论(0)

1亿VIP精品文档

相关文档