Hi all, you may have read my post regarding bars and values and stuff, well I've got that bit figured out now but as my programme is expanding, so is the number of records being parsed into it!

I'm working out a percentage of 2 groups of people:

Number of people from the UK
Number of people from outside of the UK


Once the number has been calulated I print a percentage of that value compaired to the other value in the window...


1 person from the UK -so the value of this is now 1
0 people from outside the UK -so the value of this is still null (0)

Now I'm working out the percentage as follows: (100 being 100%)

100 / [sum of the values of UK and outside UK] * [the value of UK]


100 / [1]*[1] = 100%

I'm having a problem when the UK or outside the UK value goes above 100 as the percentage for both values drops to 0%... How can this be resolved without the original percentage going above 100?

Thanks for reading, I look forward to reading your suggestions!!


9 Years
Discussion Span
Last Post by covertx

Thanks for your reply!

I've tried that way before (it makes a lot more sense!) But for some reason it doesn't like doing 2 values, and so sets the final output to 2 0%s!

Any other ideas?


But for some reason it doesn't like doing 2 values

I don't understand what you mean?

UK = 50;
NotUK = 50;

SUM = UK + NotUK; //50 + 50 = 100

PERCENTUK = (UK/SUM)*100 //(50/100) * 100 = 50%
PERCENTNOTUK = (NotUK/SUM)*100 //as above


did you try converting them to floats? if working with integers, when dividing 50 by 100, the result might round to 0.

hope this helped


Sorry I took so long to reply! I've actually sorted out the problem! By using Math.Round and assigning the output value to an integer (int)(... The problem is solved and runs beautifully!

Thanks for your replys though!

Take care

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.