Make a Positive Number - Negative-VBForums
Results 1 to 11 of 11

Thread: Make a Positive Number - Negative

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2002
    Posts
    63

    Post 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. #2
    Member
    Join Date
    Jul 2002
    Posts
    36
    if number > 0 then number = number * -1

  3. #3
    PowerPoster
    Join Date
    Aug 2001
    Location
    new jersey
    Posts
    2,904
    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. #4
    Addicted Member
    Join Date
    Aug 2002
    Location
    London UK
    Posts
    255

    Talking

    Hmm, you know actually that isn't true:

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

    But I'm sure you knew that...
    Not at all related to sheep...

  5. #5
    PowerPoster
    Join Date
    Aug 2001
    Location
    new jersey
    Posts
    2,904
    hm ... I seem to have had a brain fart on that one

  6. #6
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011
    you can make a number negative just by multiplying it with -1 or just puttiing - sign before the variable..
    GOD is One.
    MCP,SCPJ2,CCNA
    Have I helped you? don't say thanks,
    Just give me reputation points. Can see beneath my avatar? ...

    My Utilities with code
    Extended Form Events Control
    I am a hard worker, i hardly work

  7. #7
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    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
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  8. #8
    PowerPoster
    Join Date
    Aug 2001
    Location
    new jersey
    Posts
    2,904
    sounds like what you want is the absolute value. see "abs" function

  9. #9
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    If you can't do simple addition/subtraction, maybe you should choose a new career track...
    -----------------------------------------
    -RJ
    rjlohan@alumni.uts.edu.au
    -----------------------------------------

  10. #10
    Hyperactive Member Blinky Bill's Avatar
    Join Date
    Mar 2002
    Location
    Happily munching on the greenery in your garden
    Posts
    349
    if i understand you right you want this

    intDiffQ = intDiffQ - (intDiffQ * 2)
    We don't know what's wrong. . . So the best bet might be to remove something surgically.

  11. #11
    Fanatic Member Slaine's Avatar
    Join Date
    Jul 2002
    Posts
    641
    If intNumber is a variable that contains either a negative or positive value then:

    VB Code:
    1. intNegativeNumber = - Abs(intNumber)

    intNegativeNumber will always contain the negative value.
    Martin J Wallace (Slaine)

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


Click Here to Expand Forum to Full Width

Survey posted by VBForums.