opposite to ABS function

pb21

Registered User.
Local time
Today, 23:08
Joined
Nov 2, 2004
Messages
122
Is there a function to force a positive value to negative?

pass 2 returns -2

regards
 
You haven't really clarified what your wanting done, anyhow you can do as Ken suggests or assuming you have a text field called text0, on the Enter event for Text0 put this:
Text0.value = -(Text0.value)

Chris
 
Actually you will want to multiply the absolute value by -1, as aNegative * anotherNegative = PositiveResult - but you say you always want a negative

e.g. -2 * -1 = +2

therefore use e.g.: abs(-2) * -1

HTH

Regards

John
 
Actually, they didn't say what they wanted to do with a negative value...
 
Much like John's solution, just make your own function and put it in a module. Call it when needed.

Code:
Public Function nABS(lngNumber As Long) As Long
    nABS = -1 * ABS(lngNumber)
End Function

Code:
[I]From your code:[/I]

Private Sub btnSomeButton_Click()
    Dim lngNegNumber As Long
    lngNegNumber = nABS(Me.txtTextBox.Value)
End Sub
 

Users who are viewing this thread

Back
Top Bottom