Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sign revers

Status
Not open for further replies.

groner

Programmer
May 18, 2002
23
RO
How can I reverse then sign of one number ?
EX : varNumber = 12 - 14
Result varNumber = -2
I wnat varNumber positiv 2
Exist any function for this ?
Thank you man .
 
Abs(12 - 14) this should take care of it for you. If you choose to battle wits with the witless be prepared to lose.
[machinegun][hammer]
 
varnumber = 12 - 14
varnumber = Abs(varnumber)
Debug.Print varnumber

Abs() gives you the absolute value of the number. Swi
 
How can I reverse then sign of one number?

In the strict sense, to reverse the sign of any number, then multiply by -1. That will reverse the positive sign to a negative sign, and a negative sign to a positive sign.

If, on the other hand, you only want to reverse negative numbers, that is you always want a positive number, then both foada and swi have provided the best solution for that. Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top