Syntax
Public Function MathSgn(Number As Variant) As Variant
Description
This function used to return the sign of the given number.
Parameters
| Key | Description |
| Number | numeric value to know the sign for it if positive or negative,value of type Variant. |
Return value
Returns a variant value indicating the sign of the specified numeric expression.
| Parameter | Result: Sgn(Parameter) |
| 1 |
1 |
| 533 |
1 |
| -1 |
-1 |
| -533 |
-1 |
| 0 |
0 |
| true |
-1 |
| false |
0 |
| “string” |
Error : Type Mismatch. |
| unknown |
0 : uninitialized variable. |
| Null |
Error : Invalid use of null. |
| 1/0 | Error : division by zero. |
Sample
Public Sub main()AlertMessage (MathSgn(1)) ' Sgn (1) = 1 . the Alert Message will return 1AlertMessage (MathSgn(true)) ' Sgn (true) = -1 . the Alert Message will return -1AlertMessage (MathSgn(false)) ' Sgn (false) = 0 . the Alert Message will return 0End Sub
See Also