Tuesday, August 31, 2010

Visual Basic Math Function : Sgn

Purpose : The Sgn function evaluates a numExpression and returns a value based on whether the numExpression is negative, positive , or 0.

Syntax :
Sgn ( numExpression )

numExpression : Numeric expression for which you want to determine the sign.

intSign1 = Sgn ( 100 )

This example sets the variable intSign1 to 1 , indicating that the numExpression evaluated was positive.

intSign2 = Sgn ( 0 )

This example sets the variable intSign2 to 0 , indicating that the numExpression evaluated was 0.

intSign3 = Sgn ( -100 )

This example sets the variable intSign3 to -1 , indicating that the numExpression evaluated was negative.

No comments:

Post a Comment