| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 6749 人关注过本帖
标题:如何制作简单的计算器(加减乘除)
只看楼主 加入收藏
tt132414
Rank: 1
来 自:浙江
等 级:新手上路
帖 子:2
专家分:3
注 册:2009-7-27
收藏
得分:2 
zai 学习中
在学习之中,希望和大家一起进步

http://80htk./wowo/invite.php?222985obpah0_0&bbsadd=1
2009-09-26 14:52
tzx819570
Rank: 1
等 级:新手上路
帖 子:11
专家分:3
注 册:2009-9-23
收藏
得分:2 
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
 
namespace WindowsFormsApplication31
{
    public partial class Form1 : Form
    {
        public static double x = 0.0, y = 0.0,s = 0.0,z = 0.0;
 
        public Form1()
        {
            InitializeComponent();
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {
         
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            x = Convert.ToDouble(textBox1.Text);
            textBox1.Clear();
            textBox1.Focus();
            
            z = 1;
 
        }
 
        private void button5_Click(object sender, EventArgs e)
        {
            textBox1.Clear();
            textBox1.Focus();
        }
 
        private void button6_Click(object sender, EventArgs e)
        {
            if (z == 1)
            {
                y = Convert.ToDouble(textBox1.Text);
                textBox1.Clear();
                textBox1.Focus();
                s = x + y;
                textBox1.Text = Convert.ToString(s);
            }
            if (z == 2)
            {
                y = Convert.ToDouble(textBox1.Text);
                textBox1.Clear();
                textBox1.Focus();
                s = x - y;
                textBox1.Text = Convert.ToString(s);
            }
            if (z == 3)
            {
                y = Convert.ToDouble(textBox1.Text);
                textBox1.Clear();
                textBox1.Focus();
                s = x * y;
                textBox1.Text = Convert.ToString(s);
            }
            if (z == 4)
            {
                y = Convert.ToDouble(textBox1.Text);
                textBox1.Clear();
                textBox1.Focus();
                s = x / y;
                textBox1.Text = Convert.ToString(s);
            }
        }
 
        private void button2_Click(object sender, EventArgs e)
        {
            x = Convert.ToDouble(textBox1.Text);
            textBox1.Clear();
            textBox1.Focus();
            z = 2;
        }
 
        private void button3_Click(object sender, EventArgs e)
        {
            x = Convert.ToDouble(textBox1.Text);
            textBox1.Clear();
            textBox1.Focus();
            z = 3;
        }
 
        private void button4_Click(object sender, EventArgs e)
        {
            x = Convert.ToDouble(textBox1.Text);
            textBox1.Clear();
            textBox1.Focus();
            z = 4;
        }
    }
}
我做的,这个还不够完善,看懂了的话完善很简单。
2009-09-26 16:31
快速回复:如何制作简单的计算器(加减乘除)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017600 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved