If variable is a minus number or goes into a minus number

swarv

Registered User.
Local time
Today, 13:12
Joined
Dec 2, 2008
Messages
196
I have this code:

If a <> "0" Then

I would like to check to see if A is a minus number and also If I have a number in B I would like taken off of a till a gets to 0. I'll explain:

A = 10
B = 15

Take B away from A till A gets to 0 and then C will = whats left. In this case C will = 5.

How would I store this and write this?

At the moment my program delivers me minus figures.

Thanks

Martin
 
I think you want the modulo function.

Code:
c = b mod a
 
I have this code:

If a <> "0" Then

I would like to check to see if A is a minus number and also If I have a number in B I would like taken off of a till a gets to 0. I'll explain:

A = 10
B = 15

Take B away from A till A gets to 0 and then C will = whats left. In this case C will = 5.

How would I store this and write this?

At the moment my program delivers me minus figures.

Thanks

Martin
Not sure if I fully understand what you want but this code may do what you want
Code:
If  A - B < 0 then
   C = B -A
else
   C = A - B
 
end if
 
Have Your Tried
Abs Function Example

This example uses the Abs function to compute the absolute value of a number.
Dim MyNumberMyNumber = Abs(50.3) ' Returns 50.3.MyNumber = Abs(-50.3) ' Returns 50.3.This will change any number to a positive number Regards - Richard
 

Users who are viewing this thread

Back
Top Bottom