Sgn()

Syntax

Sgn(n)

Remarks

Determines whether n is positive, negative, or 0 (zero).

Value

Explanation

0 (zero)

If n is 0 (zero)

–1

If n is a negative number

1

If n is a positive number


Example

This example compares two values. If the difference is negative, a message box is displayed.


maySales = 1200
juneSales = 1000
difference = juneSales - maySales
If Sgn(difference) = -1 Then
    MsgBox "Sales fell by" + Str$(Abs(difference)) + " dollars!"
End If

See Also

Abs(), Int(), Rnd()