|
-
Aug 25th, 2000, 03:56 PM
#1
Thread Starter
Frenzied Member
is there some code that I can write so that like if I have -3 it auto maticly turns in into 3?
NXSupport - Your one-stop source for computer help
-
Aug 25th, 2000, 03:56 PM
#2
Thread Starter
Frenzied Member
oh yea, I dont want to remove one character and also, if its a positive, I want to turn it into a negative
NXSupport - Your one-stop source for computer help
-
Aug 25th, 2000, 03:58 PM
#3
Fanatic Member
Negative to positive:
Code:
Dim Number As Integer
Number = -5
Number = Abs(Number)
Positive to negative:
Code:
Dim Number As Integer
Number = 5
Number = Number - (2 * Number)
-
Aug 25th, 2000, 04:00 PM
#4
Hyperactive Member
try this:
dim i as integer
If i > 0 then
i = i - (i*2)
else
If i < 0 then
i = i + (i*2)
else
end if
end if
-
Aug 25th, 2000, 04:06 PM
#5
Thread Starter
Frenzied Member
NXSupport - Your one-stop source for computer help
-
Aug 25th, 2000, 04:08 PM
#6
Fanatic Member
Thanks for the credits.
-
Aug 25th, 2000, 04:09 PM
#7
newnumber = abs(number) * sgn(number) * -1
-
Aug 25th, 2000, 04:13 PM
#8
Guru
Why so much code? 
Change a number from positive to negative and from negative to positive in one simple instruction:
Code:
TheNumber = -TheNumber
-
Aug 25th, 2000, 04:15 PM
#9
Thread Starter
Frenzied Member
becuase I have an integer
and I'm not sure if this will work:
intb = -intb
but I got what I needed, I needed it for the link above
NXSupport - Your one-stop source for computer help
-
Aug 25th, 2000, 04:20 PM
#10
-
Aug 25th, 2000, 04:22 PM
#11
or you can use Abs
Code:
TheNegToPos = Abs(TheNegToPos)
it gives the absolute value of a number.
-
Aug 25th, 2000, 04:27 PM
#12
Thread Starter
Frenzied Member
I think thats what I used, read above (oetje's post)
NXSupport - Your one-stop source for computer help
-
Aug 25th, 2000, 04:31 PM
#13
abs would give only change a negative number to a positive number and not the vice versa.
Yonatan's code would be the best if the sign is to be changed for both positive and negative numbers.Otherwise abs is just fine.
-
Aug 25th, 2000, 04:33 PM
#14
Thread Starter
Frenzied Member
do you guys read the first posts? for the backward thing, oetje used another medthod.
NXSupport - Your one-stop source for computer help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|