标题:求指教:怎么才能让我的数字能输入几位,显示几位的大学。
只看楼主
肖亭
Rank: 1
来 自:湖北黄冈
等 级:新手上路
帖 子:11
专家分:0
注 册:2013-4-7
结帖率:100%
已结贴  问题点数:15 回复次数:8 
求指教:怎么才能让我的数字能输入几位,显示几位的大学。
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
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int z, g, s, b, q, i;
            string a;
            a = textBox1.Text;
            z = Convert.ToInt32(a);
            i = a.Length;
            g = z % 10;
            s = z / 10 % 10;
            b = z / 100 % 10;
            q = z / 1000 % 10;
            if (i > 2 & i < 3)
            {

            }
            if (i > 4)
             {
             MessageBox.Show("你输入的数字以超出范围", "提示信息");
             }
            else
            {
                    switch (q)
                    {
                        case 9: label1.Text = "玖"; break;
                        case 8: label1.Text = "捌"; break;
                        case 7: label1.Text = "柒"; break;
                        case 6: label1.Text = "陆"; break;
                        case 5: label1.Text = "伍"; break;
                        case 4: label1.Text = "肆"; break;
                        case 3: label1.Text = "叁"; break;
                        case 2: label1.Text = "贰"; break;
                        case 1: label1.Text = "壹"; break;
                        case 0: label1.Text = "零"; break;
                    }

                    switch (b)
                    {
                        case 9: label1.Text = label1.Text + "玖"; break;
                        case 8: label1.Text = label1.Text + "捌"; break;
                        case 7: label1.Text = label1.Text + "柒"; break;
                        case 6: label1.Text = label1.Text + "陆"; break;
                        case 5: label1.Text = label1.Text + "伍"; break;
                        case 4: label1.Text = label1.Text + "肆"; break;
                        case 3: label1.Text = label1.Text + "叁"; break;
                        case 2: label1.Text = label1.Text + "贰"; break;
                        case 1: label1.Text = label1.Text + "壹"; break;
                        case 0: label1.Text = label1.Text + "零"; break;
                    }
                            switch (s)
                            {
                                case 9: label1.Text = label1.Text + "玖"; break;
                                case 8: label1.Text = label1.Text + "捌"; break;
                                case 7: label1.Text = label1.Text + "柒"; break;
                                case 6: label1.Text = label1.Text + "陆"; break;
                                case 5: label1.Text = label1.Text + "伍"; break;
                                case 4: label1.Text = label1.Text + "肆"; break;
                                case 3: label1.Text = label1.Text + "叁"; break;
                                case 2: label1.Text = label1.Text + "贰"; break;
                                case 1: label1.Text = label1.Text + "壹"; break;
                                case 0: label1.Text = label1.Text + "零"; break;
                            }
                            switch (g)
                            {
                                case 9: label1.Text = label1.Text + "玖"; break;
                                case 8: label1.Text = label1.Text + "捌"; break;
                                case 7: label1.Text = label1.Text + "柒"; break;
                                case 6: label1.Text = label1.Text + "陆"; break;
                                case 5: label1.Text = label1.Text + "伍"; break;
                                case 4: label1.Text = label1.Text + "肆"; break;
                                case 3: label1.Text = label1.Text + "叁"; break;
                                case 2: label1.Text = label1.Text + "贰"; break;
                                case 1: label1.Text = label1.Text + "壹"; break;
                                case 0: label1.Text = label1.Text + "零"; break;
                            }

                        }
                    }
                }
            }
搜索更多相关主题的帖子: private public namespace 
2013-05-29 23:57
肖亭
Rank: 1
来 自:湖北黄冈
等 级:新手上路
帖 子:11
专家分:0
注 册:2013-4-7
得分:0 
不好意思打错了,是大写。
2013-05-29 23:59
csharpluntan
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:7
帖 子:197
专家分:1122
注 册:2013-4-24
得分:4 
没看明白,详细点

投之以桃,报之以李
2013-05-30 10:01
zhangjing198
Rank: 2
等 级:论坛游民
帖 子:54
专家分:76
注 册:2013-4-2
得分:4 
你运行后,错误提示是什么?命名空间名字最好还是英文吧
2013-05-30 10:28
Maick
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:32
帖 子:251
专家分:1314
注 册:2012-9-21
得分:4 
你可以用substring()这个方法截取字符..不用搞到莫这么复杂.
2013-05-30 11:32
QJlin
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:3
帖 子:186
专家分:560
注 册:2013-5-18
得分:4 
if (i > 2 & i < 3)
            {

            }
            if (i > 4)
             {
             MessageBox.Show("你输入的数字以超出范围", "提示信息");
             }
            else
            {}
就你这个判断我都感觉不太对了!

慢慢前进走,不求一步登天,只求慢慢前进
2013-05-30 12:53
肖亭
Rank: 1
来 自:湖北黄冈
等 级:新手上路
帖 子:11
专家分:0
注 册:2013-4-7
得分:0 
回复 6楼 QJlin
谢谢。
2013-05-30 18:27
肖亭
Rank: 1
来 自:湖北黄冈
等 级:新手上路
帖 子:11
专家分:0
注 册:2013-4-7
得分:0 
回复 5楼 Maick
嗯。谢谢。
2013-05-30 18:29
肖亭
Rank: 1
来 自:湖北黄冈
等 级:新手上路
帖 子:11
专家分:0
注 册:2013-4-7
得分:0 
回复 4楼 zhangjing198
谢谢。
2013-05-30 18:29



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




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

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