By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,558 Members | 1,699 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,558 IT Pros & Developers. It's quick & easy.

Percentages

P: n/a
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.
Feb 14 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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

Feb 14 '06 #2

P: n/a
Don

Sorry to butt in but . . . , you can't use integers to calculate
percentages unless you significantly modify the approach.

Don

On 14 Feb 2006 14:53:52 -0800, jr***@blackstaronline.net wrote:
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

Feb 15 '06 #3

P: n/a
Whoops, my bad, Thanks for catching that. Don is absolutely correct.
Integer data type is NOT what you would want to use to calculate that
equation.

Sorry for leading you down the wrong path....my bad.
Jeremy Reid
http://blackstaronline.net/hgtit

Feb 15 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.