在textBox1里面输入0到9的正数,保留两位小数,比如(12334.34),然后怎么逐个放进不同的label里面(label不能超过11位):12.3  label1放入3,label2放入2,labe1放入1,省略“.” ,请各位大哥把这个段代码写完整,谢谢了          

解决方案 »

  1.   

    保留两位小数
    double d;   
    double.Parse(String.Format("{0:N}",d));  double x = double.Parse("");
    double y = x % 0.01;
    double z = x - y;Char[] arr=TextBox1.Text.Replace(".","").ToCharArray();
    arr[0]
      

  2.   

    namespace WindowsFormsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private void textBox1_Validated(object sender, EventArgs e)
            {
                ClearLabelText();
                var numValue = this.textBox1.Text.Replace(".", "");
                int j = 1;
                for (int i = numValue.Length-1; i >= 0; i--)
                {
                    this.Controls["Label" + (j++).ToString()].Text = numValue[i].ToString();
                }        }        private void ClearLabelText()
            {
                for (int i = 1; i < 11; i++)
                {
                    this.Controls["Label" + i.ToString()].Text = string.Empty;
                }
            }
        }
    }这样行么?