can someone give me a code of auto calculation.
i have 5 textbox,qty.text price.text gross.text discount.text and netmount.text.

for example price is 35.00, then if the quantity is 2,value of 35.00 * 2 inserted into gross, then i got discount 25%, the total will be inserted into netmount.text.

hope you can understand. i'm total newbies in this.

3
Contributors
4
Replies
6
Views
7 Years
Discussion Span
Last Post by zarifin99ska

can someone give me a code of auto calculation.
i have 5 textbox,qty.text price.text gross.text discount.text and netmount.text.

for example price is 35.00, then if the quantity is 2,value of 35.00 * 2 inserted into gross, then i got discount 25%, the total will be inserted into netmount.text.

hope you can understand. i'm total newbies in this.

Try out the logic

protected void btnOk_Click1(object sender, EventArgs e)
{
float Price = Convert.ToInt32(txtPrice.Text);
float quantity = Convert.ToInt32(txtQuantity.Text);
float discount = Convert.ToInt32(txtDiscount.Text); ; // Always discount will be in Percentage and has to be below 100%
float netTotal;
float gross;
float totalDiscount;

//Consider Gross and Net Amount are label
gross = Price * quantity;
totalDiscount = (discount / 100) * gross;
netTotal = gross - totalDiscount;
}

Now you can assign the Gross and Net Amount in the respective text boxes.

Hope this helps...!!

Mark as "solved" if this helps to solve your requirement.

Posting C# code in a VB.NET Forum is like a drunk driver, careless.

You might need this to figure out the C# code posted by sundarchum .

Edited by codeorder: n/a

how about not using button? like txtprice_textchange or something.

its auto calculate.

nevermind, i solved it. thanks.