Sgn (function)

Syntax Sgn (number)
Description Returns an Integer indicating whether a number is less than, greater than, or equal to 0.
Comments Returns 1 if number is greater than 0. Returns 0 if number is equal to 0. Returns ???1 if number is less than 0. The number parameter is a numeric expression of any type. If number is Null , then a runtime error is generated. Empty is treated as 0.
Example This example tests the product of two numbers and displays a message based on the sign of the result.
Sub Main()
????a% = -100
????b% = 100
????c% = a% * b%
????Select Case Sgn(c%)
????????Case -1
????????????MsgBox "The product is negative " & Sgn(c%)
????????Case 0
????????????MsgBox "The product is 0 " & Sgn(c%)
????????Case 1
????????????MsgBox "The product is positive " & Sgn(c%)
????????End Select
End Sub
See Also Abs (function).