Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Always return a positive number

Status
Not open for further replies.

GSMike

Programmer
Feb 7, 2001
143
US
Is there a way, without going through all the &quot;If x < 0 then x=0-x&quot;, to make sure your calculation always returns a positive number?
For example, I am calculating percentages, some of which are <<negative number>> / divisor, other of which are not. Is there an easy way to say, &quot;just give me a positive percentage&quot; on the output?
The reason it's an issue is that i have about 60 variables, so it takes a lot of time to test every one.
Thanks in advance.
Mike Kemp
michael.kemp@gs.com
 
Hi Mike,

Try using:-

Dim iNumber as integer
iNumber = Abs(-10)

'iNumber Returns 10



Codefish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top