Mfwamba Tshimanga

Mfwamba Tshimanga

  • NA
  • 155
  • 46.2k

converting my textbox in decimal mode...

Dec 11 2014 7:37 AM
Hi!

I need to convert all my textbox in decimal number. Even at the final result should appear ONLY with at least the two decimals number at maximum (for instance 7845,56).

This is my codes:

private void txtPreco1Retalho_KeyUp(object sender, KeyEventArgs e)
        {
            if (string.IsNullOrEmpty(txtPreco1Retalho.Text))
            {
                return;
            }
            double preco1;
            double preco2;
            double preco3;
            double resultp1p2p3;
            preco1 = Convert.ToDouble(txtPreco1Retalho.Text);
            preco2 = Convert.ToDouble(txtPreco2Retalho.Text);
            preco3 = Convert.ToDouble(txtPreco3Retalho.Text);
            resultp1p2p3 = (preco1 + preco2 + preco3) / 3;
            txtMediaRetalho.Text = resultp1p2p3.ToString();
        }



Answers (4)