4
Reply

VAT Calculation Problem

Ask a question
mike Delvotti

mike Delvotti

13y
2.8k
1
Guys, I have a formular for calculating VAT it's most likely not the best but it works. My problem is now that I have to add a value from damage_WaiverTextBox.Text to the final total_ChargeTextBox.Text as the value in damage_WaiverTextBox is zero rated VAT and just wants to be added to the total. I Hope I make sense.

The current code is:

decimal subtotal = 0.00M,
                VATRate = 0.00M,
                VAT,
                Total;           

try
            {
                subtotal = decimal.Parse(subtotalTextBox.Text);
            }
            catch (FormatException)
            {
                MessageBox.Show("The value you entered for the " +
                                "Input Amount is not valid");
            }

            try
            {
                VATRate = decimal.Parse(vATrateTextBox.Text);
            }
            catch (FormatException)
            {
                MessageBox.Show("Wrong Value: The VAT rate must " +
                                "be a value between 0 and 100");
            }

            decimal I = VATRate / 100;
            VAT = subtotal * I;
            Total = subtotal + VAT;
            vATTextBox.Text = VAT.ToString("F2");
            total_ChargeTextBox.Text = total_ChargeTextBox.Text = Total.ToString("F2");


Answers (4)