P pb21 Registered User. Local time Today, 23:08 Joined Nov 2, 2004 Messages 122 Apr 13, 2005 #1 Is there a function to force a positive value to negative? pass 2 returns -2 regards
KenHigg Registered User Local time Today, 18:08 Joined Jun 9, 2004 Messages 13,327 Apr 13, 2005 #2 *-1 ???
D dopedealer Systems Analyst Local time Today, 23:08 Joined Apr 6, 2005 Messages 145 Apr 13, 2005 #3 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
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
john471 Registered User. Local time Tomorrow, 08:08 Joined Sep 10, 2004 Messages 392 Apr 13, 2005 #4 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 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
KenHigg Registered User Local time Today, 18:08 Joined Jun 9, 2004 Messages 13,327 Apr 13, 2005 #5 Actually, they didn't say what they wanted to do with a negative value...
D dopedealer Systems Analyst Local time Today, 23:08 Joined Apr 6, 2005 Messages 145 Apr 13, 2005 #6 KenHigg said: Actually, they didn't say what they wanted to do with a negative value... Click to expand... thats always the case....
KenHigg said: Actually, they didn't say what they wanted to do with a negative value... Click to expand... thats always the case....
M modest Registered User. Local time Today, 18:08 Joined Jan 4, 2005 Messages 1,220 Apr 13, 2005 #7 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
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