See Also Example
Returns an integer indicating the sign of a number.
Syntax
Sgn(number)
Remarks
The argument number can be any valid numeric expression Its sign determines the value returned by the Sgn function:
If number > 0, then Sgn(number) returns 1.
If number = 0, then Sgn(number) returns 0.
If number < 0, then Sgn(number) returns -1.
Math Functions
The example uses Sgn to determine the sign of a number. To try this example, paste the code into the Declarations section of a form. Then press F5 and click the form.
Sub Form_Click ()
Dim Msg, Number ' Declare variables.
Number = InputBox("Enter a number.") ' Get user input.
Select Case Sgn(Number) ' Evaluate user input.
Case 0 ' Zero.
Msg = "You entered zero."
Case 1 ' Positive.
Msg = "You entered a positive number."
Case -1 ' Negative.
Msg = "You entered a negative number."
End Select
MsgBox Msg ' Display results.
End Sub