Israel

Israel

  • 962
  • 1.2k
  • 138.2k

To link two pices of codes with condition

Jan 6 2020 9:24 AM
Hi,
 
I have four textboxs (txtResultA, txtResultB, txt_SoldForResultA, txt_SoldForResultB).
 
The two txtBoxes: txtResultA, txtResultB doing one operation. But when one of these txtBoxes have a number superior to another one. The result should be displayed on txt_SoldForResultA or txt_SoldForResultB.
 
For example, txtBoxA.Text (100) – txtBoxB.Text (70) = 30 (should appear on txt_SoldForResultA).
 
Another example is, txtBoxA.Text (70) – txtBoxB.Text (100) = 30. For this result should be appear on txt_SoldForResultB.
double d1, d2, total0;
double.TryParse(txtBoxA.Text, out d1);
double.TryParse(txtBoxB.Text, out d2);
total0 = d1 - d2;
txtBox_SoldForA.Text = total0.ToString("N2");
/////// Need to link these two pieces of code to do what I explained
double d3, d4, total1;
double.TryParse(txtBoxA.Text, out d3);
double.TryParse(txtBoxB.Text, out d4);
total1 = d3 - d4;
txtBox_SoldForB.Text = total1.ToString("N2");

Answers (4)