Make a Positive Number - Negative-VBForums

# Thread: Make a Positive Number - Negative

1. ## Make a Positive Number - Negative

How do i make a positive number which is assigned to a variable, a negative one.

So

PA = (Aptelev) - (intDiffQ)

If intDiffQ was positive, how do i make it negative before storing it in PA. Is there a Function to it?

the reason I ask is because sometimes the value of Aptelev is -12 and the value of intDiffQ is Positive. I want the answer to be positive but i keep getting a negative number!

Any ideas?

2. if number > 0 then number = number * -1

3. well, math is a lot like that. If you subtract a negative number from a negative number, you'll get a negative number.

sounds like what you want is the absolute value. see "abs" function

4. Hmm, you know actually that isn't true:

(-4) - (-8) = +4

But I'm sure you knew that...

5. hm ... I seem to have had a brain fart on that one

6. you can make a number negative just by multiplying it with -1 or just puttiing - sign before the variable..

7. Originally posted by moinkhan
you can make a number negative just by multiplying it with -1 or just puttiing - sign before the variable..
that will only work if the number = positive

-(-5) = 5
-(5) = -5
a = -5
-a = 5

8. sounds like what you want is the absolute value. see "abs" function

9. If you can't do simple addition/subtraction, maybe you should choose a new career track...

10. if i understand you right you want this

intDiffQ = intDiffQ - (intDiffQ * 2)

11. If intNumber is a variable that contains either a negative or positive value then:

VB Code:
`intNegativeNumber = - Abs(intNumber)`

intNegativeNumber will always contain the negative value.

#### Posting Permissions

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

Featured