473,503 Members | 1,787 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Percentages

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
3 1574
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1161
by: Avinash Dhoot | last post by:
Hi, I have a 5 row table with the following values. key value 1 5 2 10 3 15 4 15 5 5
0
3051
by: michael | last post by:
I've got a 3-column layout using percentages to define width of each div-column. #left-col { width: 20%; background-color: green; float:left; } #center-col { width: 60%; background-color: blue;...
1
2502
by: Megan | last post by:
quick summary: i'm having problems trying to group fields in a report in order to calculate percentages. to calculate percentages, i'm comparing the results from my grouped fields to the totals....
2
4122
by: Dot net work | last post by:
Hello. Is it possible to build up a dynamic server side table, and specify the column widths as percentages? I've tried this: Set the table width to 100%, then: FirstColumn.Width = New...
26
2203
by: Mike Barnard | last post by:
Hi all. I am playing with html and css. I don't (yet) have a working site, I'm just trying to build a working, basic template I can use for a couple of ideas I have. I recall reading a...
5
1875
by: Chris H | last post by:
I am wanting to write a function for a poker league manager that will detrmine players finishing points in a tournament depending on the amount of players that played... In other words when the...
1
1679
by: Bob Alston | last post by:
I need to produce a report like this Color: # % ------ --- --- White 10 20 Black 25 50 other 15 30 ---- ---- Total 50 100
9
27790
by: AZKing | last post by:
Hi all, I would like to know how do you go about calculating percentages in Access. For example, in a form I have 3 combo boxes with drop down menus where a user can select "Yes" or "No" and a...
3
2063
by: martin DH | last post by:
Access 2003 I have a table (TASKS) filled with data from an external source. The table lists several tasks for employees to complete and has a text field (STATUS) that identifies where in the...
0
1345
by: marcopolo8 | last post by:
Wierd thing is happening during my xHTML development. When I set the width attribute of a text field in a form and use percentages, if the text field's value is extremely long, IE6 automatically...
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7074
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7322
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6982
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5572
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5000
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3161
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1501
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.