Sign
From Xojo Documentation
Method
Returns the sign of the number passed to it.
Syntax
result=Sign (value)
Part | Type | Description |
---|---|---|
result | Integer | The sign of value. Returns -1 if value is negative, 0 if value is zero, and 1 if value is positive.
If you pass a string or some other incorrect data type, result is 0. |
value | Double | The number being passed to the function. |
Examples
The following example determines the sign of the number passed to it.
Var result As Integer
If TextField1.Value <> "" Then
result = Sign(TextField.Value).ToInteger)
MessageBox(result.ToString)
Else
MessageBox("Please enter a number!")
End If
If TextField1.Value <> "" Then
result = Sign(TextField.Value).ToInteger)
MessageBox(result.ToString)
Else
MessageBox("Please enter a number!")
End If
See Also
Abs function.