?
Solved

Calculating percentage...

Posted on 2007-04-01
6
Medium Priority
?
1,937 Views
Last Modified: 2008-01-09
I need help calculating the percentage of two numbers.  I have two Labels with the values and need to calculate the percentage.

RealPercentage = CDec(Me.lblActualMilestoneHours.Text) \ CDec(Me.lblApprovedMilestone.Text)

The value of lblActualMilestoneHours is 5
The value of lblApprovedMilestone is 2

0
Comment
Question by:convertix
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 67

Assisted Solution

by:sirbounty
sirbounty earned 600 total points
ID: 18834274
Hello convertix,
Where are you getting hung up?
What are the meanings of those labels?
I'd suppose either you're getting an error, or you're getting incorrect data.
Have you tried flipping the values?
RealPercentage = CDec(Me.lblApprovedMilestone.Text) / CDec(Me.lblActualMilestoneHours.Text)

Or is it the you were using the backslash, rather than the forward slash?

~sirbounty
0
 

Author Comment

by:convertix
ID: 18834332
The lblApprovedMilestone is the total amount of hours and the lblActualMilestoneHours is the current number of hours in the current project.  This program is for keeping track of how many hours a developer is taking to complete a project.  The total approved hours is 5 for this milestone and the actual current hours on the project is 2 so I want to figure out the percentage done.  When I use my calculator I get the percentage 40%.  When I take the 5 and divide it by two in VB.NET I get 2 and I can't remember or figure out how to get the proper percentage.
0
 

Author Comment

by:convertix
ID: 18834335
I meant to say, when I take 2 and divide it by 5.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:convertix
ID: 18834336
And also meant to say....I get 0 (instead of 2)
0
 
LVL 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 600 total points
ID: 18834439
Look CLOSELY at the SLASHES in use.

Your code is using a Backslash "\" which means INTEGER Division will be peformed:
http://msdn2.microsoft.com/en-us/library/0e16fywh.aspx

sirbounty has corrected the problem by replacing it with a Forward Slash "/" which performs regular division.

So keep the variables in the order you have them but use the correct Operator:

    RealPercentage = CDec(Me.lblActualMilestoneHours.Text) / CDec(Me.lblApprovedMilestone.Text)
0
 
LVL 3

Accepted Solution

by:
r1937 earned 800 total points
ID: 18835349
ok ok math problem....

>>>>The lblApprovedMilestone is the total amount of hours and the lblActualMilestoneHours is the current number of hours in the current project.  This program is for keeping track of how many hours a developer is taking to complete a project.  The total approved hours is 5 for this milestone and the actual current hours on the project is 2 so I want to figure out the percentage done
<<<<<

Dim RealPercentage As Decimal
RealPercentage = CDec(Me.lblActualMilestoneHours.Text) / CDec(Me.lblApprovedMilestone.Text) * 100

r1937
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question