Get Number Sign Method
The Get Number Sign method returns a value that identifies the sign of a number. It returns a different value depending on the following value of the number:
Number is less than zero. It returns negative 1.
Number is equal to zero. It returns 0.
Number is greater than zero. It returns 1.
Format
Sgn(number)
This method uses the same arguments as the Get Absolute Value method. For more information, see Get Absolute Value Method.
Example
The following example examines the value of the profit variable. If this value is a negative number, then it displays 0 for profit:
Sub Button_Click
Dim profit as Single
Dim expenses
Dim sales
expenses = 100000
sales = 200000
profit = Val(sales)-Val(expenses)
If Sgn(profit) = 1 then
‘Yeah! We turned a profit!
ElseIf Sgn(profit) = 0 then
‘Okay. We broke even.
Else
‘Uh, oh. We lost money.
End If
End Sub