Results 1 to 4 of 4

Thread: [RESOLVED] convertion from +ve value to -ve value

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2007
    Posts
    5

    Resolved [RESOLVED] convertion from +ve value to -ve value

    hi..
    how to convert decimal +ve value to decimal -ve value in vb 6.0
    eg: value in text box = 3 , then i want convert it to -3
    can anyone help me..
    thanks...

  2. #2
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: convertion from +ve value to -ve value

    textbox.text = val(textbox.text) * -1
    ===================================================
    If your question has been answered, mark the thread as [RESOLVED]

  3. #3
    Addicted Member kewakl's Avatar
    Join Date
    Oct 2006
    Location
    between keyboard and chair
    Posts
    220

    Re: convertion from +ve value to -ve value

    in addition to Pasvorto's example, you could subtract the Val() from 0.

    veNEG = 0 - ve
    Do not use if shrinkwrap is broken or missing!
    I'm learning how to fish, too!

  4. #4
    New Member
    Join Date
    Apr 2007
    Location
    Scotland
    Posts
    7

    Re: convertion from +ve value to -ve value

    Easiest way to do it would be to just multiply the number by -1. if you multiply 500 by -1 you get -550 and if you multiply -500 by -1 you get 500. Probably the best way to do it.

    Though in the example given by Pasvorto, if you are using the val() function dont! Use clng(), cint(), etc... insted as tehy are about three times as fast.

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