Click here to Skip to main content
15,742,655 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
I have 3 textboxes txtamont.text , txtTotalAmount.text and txtDue.text Simultaneouly .When i have enter in txtamont.text 10000 and Totla amount is 15000 then in how to display Due amount in txtDue.text automatically remaining amount please tell me anyone plz
Posted

Hi,

You can use TextChanged event to calculate, check txtamont.text and txtTotalAmount.text are not blank and parse them they are numeric
then Set
C#
txtDue.Text =Convert.ToDecimal(txtTotalAmount.Text) -Convert.ToDecimal(txtamont.Text)


or else you can create a class CalDueAmt where you expose two property


On Text Chnage just Set TotalAmt and Amt get calculated value

C#
class CalDueAmt
{
private decimal _TotalAmt;
public decimal TotalAmt { get { return _TotalAmt;}
                          set { _TotalAmt=value; Calculate();}

private decimal _Amt;
public decimal Amt { get { return _Amt;}
                          set { _Amt=value; Calculate();}

private void Calculate()
{
txtDue.Text=_TotalAmt-_Amt;
}
}


you should use this as a nested class of That from where calculation required .
 
Share this answer
 
in the text changed event of the second text box. write the calculation.



txtDue.Text =Convert.ToDecimal(txtTotalAmount.Text) -Convert.ToDecimal(txtamont.Text)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900