How Do I Takeaway a Percentage from a Value.

  • Thread starter Thread starter Gary Simpson
  • Start date Start date
G

Gary Simpson

Guest
Hi Good People.

I have a form with Textboxes

TextBox1 = txtEnterNoItems ( This is for entering the Amount of Items)

Textbox2 = txtEntertDiscount ( This is For Setting the Percentage Rate)

Textbox3 = txtSubTotal (This is for the Pre-Value of Items before Tax)

Textbox4 = txtInsertPrice ( This is for inserting the price of one item)

My Question is How do I Minus a Percentage from Textbox3, From a Percentage Value in Texbox2.

Without using textbox2 Everything works fine using a value of (0) in textbox2. I am looking for the formula the enables me to minus the Percentage from the Sub Total Textbox (Textbox3) Using the Percentage Value in Textbox2.

This will be in a button click event. Code I have is Below..

Private Sub cmdCalculateItems_Click(sender As Object, e As EventArgs) Handles cmdCalculateItems.Click
If IsNumeric(txtEnterNoItems.Text) Then

Dim i As Double = txtEnterNoItems.Text
i -= txtEntertDiscount.Text
txtSubTotal.Text = i.ToString
txtSubTotal.Text = FormatCurrency(txtSubTotal.Text)

txtVAT1.Text = txtSubTotal.Text * Val(txtVATRate.Text)

Dim Sum1 As Double = txtInsertPrice.Text
Dim Sum2 As Double = txtEnterNoItems.Text
Dim Sum3 As Double = txtSubTotal.Text
Dim Sum4 As Double = txtVATRate.Text


i *= txtVATRate.Text
txtVAT1.Text = i.ToString
txtVAT1.Text = FormatCurrency(txtVAT1.Text)

'txtTotal1.Text = (Sum1 + Sum3) * Sum2
txtSubTotal.Text = Sum1 * Sum2
txtVAT1.Text = Sum2 + Sum3 * Sum4
txtTotal1.Text = Sum3 + Sum4

txtSubTotal.Text = FormatCurrency(txtSubTotal.Text)
txtVAT1.Text = FormatCurrency(txtVAT1.Text)
'txtTotal1.Text = FormatCurrency(txtTotal1.Text)

lbVatRateUsed.Text = txtVATRate.Text & " %"
lbPricePerItem.Text = txtInsertPrice.Text
lbAmountOfItems.Text = txtEnterNoItems.Text

lbSubTotal.Text = txtSubTotal.Text
lbVAT1.Text = txtVAT1.Text

If txtEntertDiscount.Text = "0" Then
lbDiscountUsed.Text = "No Discount Used"
Else
lbDiscountUsed.Text = txtEntertDiscount.Text & " %"

End If

Else
MessageBox.Show("Enter a valid Number", "VAT System", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If

cmdCalculateVAT1.PerformClick()

End Sub

I hope you can understand my question?

Kind Regards Gary




Gary Simpson

Continue reading...
 
Back
Top