Siebel VB Language Reference > VB Language Reference >
Sgn Function
This standard VB function returns a value indicating the sign of a number. Syntax
Sgn(number)
|
|
number |
A numeric expression for which the sign is to be determined |
Returns
If number is less than zero, -1. If number is equal to zero, 0. If number is greater than zero, 1. Example
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. 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
Related Topics
Exp Function Fix Function Int Function Log Function Rnd Function Sqr Function
|