Difference between 2 numbers

A

Adrian

Hi all,

Can anyone tell me the easiest way to get the difference
between 2 variable values?

variable A, variable B and variable C are all results of
mathmatical calculations

I need to programmatically find out whether A or B has the
greatest difference compared to variable C and by how much

for example Let A = 10, B = 2, C = 4

A has the greatest difference, the difference being 6

Any ideas? I really should have paid more attention at
school !!

Thanks
 
S

Steve Lang

Yo Adrian,

using the abs function ensures positive values all 'round.

sub Foo
if abs(abs(a)-abs(c))> abs(abs(b)-abs(c)) then
msgbox "The difference between A and C is greater than the difference
between B and C"
else
msgbox "The difference between B and C is greater than the difference
between A and C"
end if

end sub

Don't know if it is the "easiest," but it is accurate.

HTH and have a great day!
Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top