JohnnyMan22 Posted September 6, 2022 at 02:57 PM Report Share #627148 Posted September 6, 2022 at 02:57 PM Boa tarde a todos, Estou com dificuldades para somar valores com casas decimais no asp.net usando o c#. Possuo 4 textboxes e pretendo que o programa some (instantaneamente) os valores que estarão a ser digitados no momento. O meu código soma apenas inteiros. Alguma sugestao? protected void TextBox1_TextChanged(object sender, System.EventArgs e) { int first = 0; int second = 0; int third = 0; int forth = 0; if (Int32.TryParse(TextBox1.Text, out second) && Int32.TryParse(TextBox2.Text, out first)&& Int32.TryParse(TextBox3.Text, out forth) && Int32.TryParse(TextBox4.Text, out third)) TextBox5.Text = (first + second + third + forth).ToString(); } Obrigado desde já. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now