Question : subtract 10% from textbox

hi,
   I have a button which when pressed changes the background colour, I also want it to deduct 10% from the total of a textbox, then when clicked, change the colour back and reapply the 10%. ....  The code so far is:

       If percent10.BackColor = Color.LightGray Then
            percent10.BackColor = Color.Red
            discountlabel.Text = "10% Discount Applied"
            lbltotal.Text = Format(Val(lbltotal.Text) / 10, "0.00")
        Else

            percent10.BackColor = Color.LightGray
            discountlabel.Text = ""
            lbltotal.Text = Format(Val(lbltotal.Text) * 0.1, "0.00")
        End If

This gives some strange results though and I can't work out where I am going wrong.  Can anyone help?

Thanks

Answer : subtract 10% from textbox

a 10% discount is NOT what you get when you divide by 10.  Rather a 10% discount is the original value MINUS10%of that original value

Discount = 0.1* OriginalValue
DiscountedValue = OriginalValue - Discount

then, to get the orginal value back again, you would add the Discount to the DiscountedValue:

OriginalValue = DiscountedValue + Discount
Random Solutions  
 
programming4us programming4us