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.

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.

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

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

how about not using button? like txtprice_textchange or something.

its auto calculate.

nevermind, i solved it. thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.