Siebel VB Language Reference > VB Language Reference >
This standard VB function returns a value indicating the sign of a number.
A numeric expression for which the sign is to be determined
If number is less than zero, -1.
If number is equal to zero, 0.
If number is greater than zero, 1.
This example tests the value of the variable profit and displays 0 for profit if it is a negative number. The subroutine uses Sgn to determine whether profit is positive, negative, or zero.
Dim profit as Single
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.
'Uh, oh. We lost money.