标题:我用windows控制台编写了一个计算器,如何在输入数字时,让数字从右向左显示 ...
只看楼主
千纸鹤女孩儿
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2011-5-6
 问题点数:0 回复次数:2 
我用windows控制台编写了一个计算器,如何在输入数字时,让数字从右向左显示呢?
这里是主要的程序代码部分,请哪位高手指点一下,本人对编程不是很了解,先谢谢了
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace 计算器
{
    public partial class Form1 : Form
    {
        double a { get; set; }
        double b { get; set; }
        double c { get; set; }
        string opt { get; set; }
        public Form1()
        {
            InitializeComponent();
        }

        private void num_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;
            this.container.Text += btn.Text;
        }
        private void opt_Click(object sender, EventArgs e)
        {
            a = Convert.ToDouble(this.container.Text);
            Button btn = (Button)sender;
            opt = btn.Text;
            this.container.Text = "";
        }
        private void c_Click(object sender, EventArgs e)
        {
            b = Convert.ToDouble(this.container .Text );
            switch (opt)
            {
                case "+":
                    c = a + b;
                    break;
                case "-": c = a - b;
                    break;
                case "*": c = a * b;
                    break;
                case "/": c = a / b;
                    break;
                case "%": c = a % b;
                    break;
                case "1/x": c = 1 / a;
                    break;
            }
            this.container.Text = c.ToString();








        }
        
        
        
    }
}
搜索更多相关主题的帖子: 计算器 windows 控制台 
2011-05-06 17:28
lucky563591
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:4
帖 子:765
专家分:2103
注 册:2009-11-18
得分:0 
输入时怎么能这样显示!
2011-06-14 08:41
promachus
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2005-11-12
得分:0 
用TextOut()前用SetTextAlign (hdc, TA_RIGHT | TA_TOP) ;
用DrawText()选择合适的uFormat参数
http://baike.baidu.com/view/1023733.htm
2013-02-19 19:19



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-339002-1-1.html




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

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