Results 1 to 5 of 5

Thread: Convert positive decimal into negative

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2000
    Posts
    1

    Question

    Hi All,

    I am doing an Access 2000 using VBA. I encounterd problem
    converting positive digit into negative one and vice versa.

    The case is like this, I had a list box when the user chose
    "withdrawal", the amount(in a textbox) will be a negative value. On the contrary, if user chose deposit, the value will remain "positive". Can someone help me with the code and or the function.

    Thanks alot.
    Markus

  2. #2
    Guest
    just do this for withdrawal

    if withdrawal = true and text1 > 0 then text1 = -text1 'self explanatory

    do this for deposit

    if deposit = true and text1 < 0 then text1 = -text1 'same thing

    i hope this works, if not then tell me so i can think up something else

  3. #3
    Addicted Member JasonGS's Avatar
    Join Date
    May 2000
    Location
    California
    Posts
    155
    I had to do something similar, I used...
    Code:
    'Negative (Withdrawl)
    Amount = Val("-" & Amount)
    'Deposit (Positive)
    Amount = Val(Amount)

  4. #4
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    if it is supposed to be negative
    Code:
    Dim numX As Integer
    numX = 45
    numX = numX - (numX * 2)
    or positive
    Code:
    Dim numX As Integer
    numX = 45
    good, luck this does work for me

  5. #5
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    To get the number from negative to positive, just use Abs function:

    Code:
    Dim intNumber As Integer
    
    'Just a test
    intNumber = -250
    
    'Make it positive
    intNumber = Abs(intNumber)
    
    
    'Make it negative
    intNumber = intNumber * -1

Posting Permissions

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



Click Here to Expand Forum to Full Width