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();
}
Loading

VulpesRank #55 · 29.2K reputationPosted Dec 11, 2014, 2:49 AM EST
Michal HabalcikRank #902 · 2.3K reputationPosted Dec 11, 2014, 2:47 AM EST
resultp1p2p3 = Math.Round((preco1 + preco2 + preco3) / 3, 2);
Mfwamba Tshimanga155 reputationPosted Dec 11, 2014, 3:04 AM EST
Michal HabalcikRank #902 · 2.3K reputationPosted Dec 11, 2014, 3:06 AM EST