LMuadDIb
asked on
percentages
hey all, my question is
to keep it simple, lets say you have a bar thats 100 hundred long, and you have a line on it thats 36 long, what percentage would that line be long?
and vice versa, if you knew the percentage the line should be... how long would the line be?
Im usually very good in math, but for some reason Im having probs with this LOL
thanks in advance =)
to keep it simple, lets say you have a bar thats 100 hundred long, and you have a line on it thats 36 long, what percentage would that line be long?
and vice versa, if you knew the percentage the line should be... how long would the line be?
Im usually very good in math, but for some reason Im having probs with this LOL
thanks in advance =)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
DOH!
I also figured out my error which was another DOH! ;)
thanx
I also figured out my error which was another DOH! ;)
thanx
Expanding on brunomsilva,
__________________________ __________ __________ ____
Part A)
To calculate it in delphi:
Percentage:=(36 div 100) * 100; //will give you the percentage of 36
PartB)
The opposite (using brunomsilva example):
Length:=(150 * (10 div 100)); //will give you the length of 15
__________________________ __________ __________ ____
Similarly if we use straight variables so that it can be changed dynamically:
Part A)
var Percentage,linelength,barl ength:Inte ger;
begin
Percentage:=(LineLength div BarLength) * 100;
end;
Part B)
var Percentamount,Linelength,b arlength:I nteger;
begin
LineLength:=(BarLength * (PercentAmount div 100));
end;
__________________________ __________ __________ ____
Regards,
Hypoviax
__________________________
Part A)
To calculate it in delphi:
Percentage:=(36 div 100) * 100; //will give you the percentage of 36
PartB)
The opposite (using brunomsilva example):
Length:=(150 * (10 div 100)); //will give you the length of 15
__________________________
Similarly if we use straight variables so that it can be changed dynamically:
Part A)
var Percentage,linelength,barl
begin
Percentage:=(LineLength div BarLength) * 100;
end;
Part B)
var Percentamount,Linelength,b
begin
LineLength:=(BarLength * (PercentAmount div 100));
end;
__________________________
Regards,
Hypoviax
I was a bit slow in typing my post!!!
ASKER
[Error] misc.pas(22): Incompatible types: 'Integer' and 'Extended'
in delphi code, if you wanted a button to be 25% of the width of the form its sitting on, how would you code it?