Sgn Function

Category: GUI » Visual Basic 6 » Function

Description: Returns an integer indicating the sign of a number Syntax: Sgn(number)

ParametersDescription
number Required. A numeric expression

Return Data Type: Variant (-1, 0 or 1) Usage / Example Code:

StatementResult / ValueRemark / Note
sgn(1) 1  
sgn(123) 1  
sgn(123.45) 1  
sgn(0) 0  
sgn(-1) -1  
sgn(-123) -1  
sgn(-123.45) -1  
sgn(unknown) 0 Uninitialized variable
sgn(null) Error Run-time error '94': Invalid use of Null
sgn("-123.45") -1  
sgn("string") Error Run-time error '13': Type mismatch
sgn(True) -1  
sgn(False) 0  
sgn() Error Compile error: Expected: expression

Related Articles:

Tags: Math Functions, vb6