Percentages

  • Thread starter Thread starter DAL
  • Start date Start date
D

DAL

I have two textboxes. One is to enter the percentage rate, and the other
text box is to enter the price of the item. What is the formula to get the
correct answer after the percentage has been subtracted from the original
price.

Example: 10% of $1 = .90

Thank you in advance, DAL.
 
Try this.

Dim prcnt as Integer = cint(txtPercent)
Dim price as Integer = cint(txtPrice)

Dim Xnum as Integer = (100 - prcnt )/100

txtFinalPrice.Text = price * Xnum

Pretty much what your doing is subtracting the entered percentage from
100 and then dividing that from 100. Then multiplying that by the
price.

Example:

100% - 10% = 90%
90/100 = .9

..9 X $1 = .90

Hope this helps,
Jeremy Reid
http://blackstaronline.net/hgtit
 
Sorry to butt in but . . . , you can't use integers to calculate
percentages unless you significantly modify the approach.

Don
 
Back
Top