Software Utilize C#, VS-2005
How to Remove Nagative Sign From Textbox. my code is:
Private void button1_Click(object sender, EventArgs e)
{
decimal t1 = 0;
decimal t2 = 0;
decimal res = 0;
t1 = Convert.ToDecimal(textBox1.Text);
t2 = Convert.ToDecimal(textBox2.Text);
res = t1 - t2;
textBox3.Text = res.ToString();
}
if t1 have value 12000 and t2 have value 20000. so result is 12000-20000 = -8000
I want to remove (-) sign from textbox. How can i do that?
Abs(value) which will convert your negative value to positive.
A common math method is abs. This computes absolute values. It removes the negative sign (if there is one) from the number and returns that.
The static Math.Abs
method is your friend.
res = Math.Abs(t1 - t2);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With