I have a couple of suggestion for you, probably it will either fix it or help to fix it.
1) Break down calculation, so you can debug easily, rather than end up with single equation with no clue of it issue.
2) Avoid passing each time to
VAL() function its an overhead. rather store it in a variable.
3) As far as i understand, you are probably losing your original value, you should have three textboxes. Lets see how:
- Take a TextBox name as
txtActualAmt with a `Text` of 3500
- Take a TextBox name as
txtTA with a `Text` of 10 <-- Change the value of this textbox
- Take a TextBox name as
txtOutputVat with a `Text` of 3500
Now use this code:
Private Sub txtTA_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtTA.TextChanged
Dim str As Double = 0
Dim actualAmount As Double = Val(txtActualAmt.Text)
Dim TA As Double = Val(txtTA.Text)
Dim percentageAmt As Double = Val(actualAmount * TA) / 100
str = actualAmount + percentageAmt
txtOutputVat.Text = str.ToString("0.00")
str = Nothing
End Sub
Result:
- If TA = 1 , txtOutputVat.Text = 3535.00
- If TA = 10, txtOutputVat.Text = 3850.00
etc..
Notice that:
str = actualAmount + percentageAmt
shows that 'str' is the sum of actual amount and percentage on it.
Hope this is waht you were trying to do.