public double numinput=0;
public bool dot = false;
if(textBox1.Text.Equals("0.")&& !dot) textBox1.Text="1";
            else textBox1.Text = textBox1.Text+"1";
            numinput = double.Parse(textBox1.Text);主要是dot在这里的用途不太理解。

解决方案 »

  1.   

    dot不就是点的意思吗
    估计是记录用户是否输入小数点的意思
    找找其他赋值的地方是不是计算器的代码?
    “0.”为默认值
    用户如果按了“.”界面还是显示“0.”再按“1”就要合成“0.1”
    如果没有按“.”就将是“1”
      

  2.   

    是我写的计算器   上面的是我参考别人的  不太理解
    我不太懂那个bool dot =false;  在下面的语句中的含义,
    还有if(textBox1.Text.Equals("0.")&& !dot) textBox1.Text="1";中的!dot的作用是什么啊
    请赐教```
      

  3.   

    你要去别的地方看看通过什么给dot赋值的,这里的代码看不出dot的作用。
      

  4.   

    我怎么也看着迷糊啊啊 。。好像!dot是什么意思?
    是不是“没有“点”的意思啊” 但是没有给dot赋值啊
      

  5.   

    这是我写的程序,上面的问题就是这里的 :
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;namespace WindowsApplicationTry
    {
        public partial class Form1 : Form
        {
            public double numinput=0;
            public double onepart =0;
            public char i;
            public bool dot = false;
            public double  baifenhao;        public Form1()
            {
                InitializeComponent();
            }        
            
            private void buttonNum1_Click(object sender, EventArgs e)
            {
                if(textBox1.Text.Equals("0.")&& !dot) textBox1.Text="1";
                else textBox1.Text = textBox1.Text+"1";
                numinput = double.Parse(textBox1.Text);
            }        private void buttonNum2_Click(object sender, EventArgs e)
            {
                if (textBox1.Text.Equals("0.") && !dot) textBox1.Text = "2";
                else textBox1.Text = textBox1.Text + "2";
                numinput = double.Parse(textBox1.Text);
            }        private void buttonNum3_Click(object sender, EventArgs e)
            {
                if (textBox1.Text.Equals("0.") && !dot) textBox1.Text = "3";
                else textBox1.Text = textBox1.Text + "3";
                numinput = double.Parse(textBox1.Text);
     
            }        private void buttonNum4_Click(object sender, EventArgs e)
            {
                if(textBox1.Text.Equals("0.")&&!dot) textBox1.Text="4";
                else textBox1.Text = textBox1.Text+"4";
                numinput = double.Parse(textBox1.Text);
     
            }        private void buttonNum5_Click(object sender, EventArgs e)
            {
                if (textBox1.Text.Equals("0.") && !dot) textBox1.Text = "5";
                else textBox1.Text = textBox1.Text + "5";
                numinput = double.Parse(textBox1.Text);
     
            }        private void buttonNum6_Click(object sender, EventArgs e)
            {
                if (textBox1.Text.Equals("0.") && !dot) textBox1.Text = "6";
                else textBox1.Text = textBox1.Text + "6";
                numinput = double.Parse(textBox1.Text);
            }        private void buttonNum7_Click(object sender, EventArgs e)
            {
                if (textBox1.Text.Equals("0.") && !dot) textBox1.Text = "7";
                else textBox1.Text = textBox1.Text + "7";
                numinput = double.Parse(textBox1.Text);
            }        private void buttonNum8_Click(object sender, EventArgs e)
            {
                if (textBox1.Text.Equals("0.") && !dot) textBox1.Text = "8";
                else textBox1.Text = textBox1.Text + "8";
                numinput = double.Parse(textBox1.Text);
            }        private void buttonNum9_Click(object sender, EventArgs e)
            {
                if (textBox1.Text.Equals("0.") && !dot) textBox1.Text = "9";
                else textBox1.Text = textBox1.Text + "9";
                numinput = double.Parse(textBox1.Text);
            }
            private void buttonNum0_Click(object sender, EventArgs e)
            {
                //textBox1.Text = textBox1.Text + "0";
                //numinput = double.Parse(textBox1.Text);
                if (textBox1.Text.Equals("0.") && !dot) textBox1.Text = "0";
                else textBox1.Text = textBox1.Text + "0";
                numinput = double.Parse(textBox1.Text);
            }
            private void buttonNumDot_Click(object sender, EventArgs e)
            {            if (!textBox1.Text.Contains(".") )textBox1.Text = textBox1.Text + ".";
                dot = true;
               // numinput = double.Parse(textBox1.Text);
                       }        private void buttonNumEqual_Click(object sender, EventArgs e)
            {            
                //textBox1.Text = (numinput + onepart).ToString();           // MessageBox.Show("分母不能为“0”", "HELP", MessageBoxButtons.OK, MessageBoxIcon.Error);
                   
        
                }        private void buttonNumPlus_Click(object sender, EventArgs e)
            {
                onepart = double.Parse(textBox1.Text);
                i = '+'; 
                textBox1.Text = "";
                
            }
            private void buttonNumSubtraction_Click(object sender, EventArgs e)
            {
                onepart = double.Parse(textBox1.Text);
                i = '-';
                textBox1.Text = "";
            }        private void button1_Click(object sender, EventArgs e)
            {
                textBox1.Text = "0.";
                dot = false;
              }        private void buttonNumMultiplication_Click(object sender, EventArgs e)
            {
                onepart = double.Parse(textBox1.Text);
                i = '*';
                textBox1.Text = "";
            }        private void buttonNumDivision_Click(object sender, EventArgs e)
            {
                onepart = double.Parse(textBox1.Text);
                i = '/';
                textBox1.Text = "";
            }        private void Form1_Load(object sender, EventArgs e)
            {
                textBox1.Text = "0.";
            }        private void button2_Click(object sender, EventArgs e)
            {
                Form2 form = new Form2();
                form.Show();
            }        private void button3_Click(object sender, EventArgs e)
            {
                switch (i)
                {
                    case '+': onepart = onepart + numinput; textBox1.Text = (onepart).ToString(); break;
                    case '-': onepart = onepart - numinput; textBox1.Text = (onepart).ToString(); break;
                    case '*': onepart = onepart * numinput; textBox1.Text = (onepart).ToString(); break;
                    case '/': if (numinput == 0)
                                  { MessageBox.Show("分母不能为“0”", "HELP", MessageBoxButtons.OK, MessageBoxIcon.Error); }                          else onepart = onepart / numinput; textBox1.Text = (onepart).ToString(); break;            }              
            }        private void buttonNumPrecentage_Click(object sender, EventArgs e)
            {
                numinput = numinput * 0.01;
                if (textBox1.Text.Equals("0.") &&  !dot) textBox1.Text = "%";
                else textBox1.Text = textBox1.Text + "%";
               // numinput = double.Parse(textBox1.Text);
            }                          
             
        }
    }