Identify negative number and convert to real

# Thread: Identify negative number and convert to real

1. Member
Join Date
Dec 1969
Posts
96

## Identify negative number and convert to real

I&#039;m sure this is a very simple operation, but I&#039;ve searched online resources and my books and I can&#039;t find the straightforward answer. I want to test a numeric value to see if it&#039;s a negative number. If it is, I want to convert it to a positive number. <BR><BR>Can someone point me in the right direction?<BR><BR>Thanks!<BR><BR>eddie

2. Senior Member
Join Date
Dec 1969
Posts
11,247

## ABS()

The Abs function returns the absolute value for a number. <BR> <BR>Negative numbers become positive. Positive numbers remain positive.

3. Senior Member
Join Date
Dec 1969
Posts
11,334

## Just use Abs(yournumber)

and it&#039;ll always be positive.

4. Senior Member
Join Date
Dec 1969
Posts
11,334

## Man I'm slow today

I&#039;ve lost twice now....<BR><BR>Guess it&#039;s time for me to give up :)

5. Senior Member
Join Date
Dec 1969
Posts
11,247

## And i checked I had it right too

Boy you are slow ;-)

6. Member
Join Date
Dec 1969
Posts
96

## RE: ABS()

Thanks!<BR><BR>But I do need to test the number to see if it&#039;s negative first. I also have positive numbers coming in on this function and I need to handle them differently. Is there a way to test the number and return whether or not it&#039;s negative?<BR><BR>Thanks again for the FAST response!<BR><BR>e

7. Senior Member
Join Date
Dec 1969
Posts
11,247

## RE: ABS()

convert it to a string <BR>if left(chr(number), 1) = "-" then<BR>NOT TESTED

8. Member
Join Date
Dec 1969
Posts
96

## RE: ABS()

Actually, I just found the answer on MSDN. <BR><BR>If Sgn(number) = -1 then<BR> &#039;it&#039;s negative - do stuff for negative num<BR>Else<BR> &#039;it&#039;s not - do stuff for positive num<BR>End If<BR><BR>Thanks again!

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•