C#取数(取十万以内的每一位的数)

需求:
两个button按钮(一个取数按钮,一个清空按钮)
一个textbox
五个lable
C#取数(取十万以内的每一位的数)_第1张图片
C#取数(取十万以内的每一位的数)_第2张图片

 		//取数
        private void button1_Click(object sender, EventArgs e)
        {
            int i = int.Parse(textBox1.Text);
            int w = i / 10000;
            label1.Text ="万:"+ w.ToString();
            int q = i % 10000 / 1000;
            label2.Text = "千:"+ q.ToString();
            int b = i % 1000 / 100;
            label3.Text = "百:" +b.ToString();
            int s = i % 100 / 10;
            label4.Text = "十:" +s.ToString();
            int g = i % 10;
            label5.Text = "个:"+ g.ToString();
            if (i>=100000)
            {
                label1.Text = "万:";
                label2.Text = "千:";
                label3.Text = "百:";
                label4.Text = "十:";
                label5.Text = "个:";
            }
        }
        //清空
        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
            label1.Text = "万:";
            label2.Text = "千:";
            label3.Text = "百:";
            label4.Text = "十:";
            label5.Text = "个:";
        }

        private void 取数02_Load(object sender, EventArgs e)
        {
            label1.Text = "万:";
            label2.Text = "千:";
            label3.Text = "百:";
            label4.Text = "十:";
            label5.Text = "个:";
        }

你可能感兴趣的:(C#取每位数)