I have a text box designTB and a double variable totaldsgn.
I cannot create the following equation because the designTB is a string and totaldsgn is a double

designTB.Text = totaldsgn

I have tried this and it still does not work

designTB.Text = totaldsgn.tostring

Any suggestions? Is there a way to make a text box a double instead of a string?

Without databinding you need to validate the input yourself:

private void button1_Click(object sender, EventArgs e)
    {
      //Set the value
      double d1 = 5.0;
      textBox1.Text = Convert.ToString(d1);
    }

    private void button2_Click(object sender, EventArgs e)
    {
      //read the value
      double d1;
      if (!double.TryParse(textBox1.Text, out d1))
      {
        textBox1.Focus();
        textBox1.SelectAll();
        MessageBox.Show("Invalid value");
        return;
      }
      //Continue with code...
    }

Thanks sknake

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.