Math.Abs Method

Returns the absolute value of any arithmetic expression.

...Math.Abs( expression )

Prerequisites

None

Parameters

expression

A required expression that evaluates to any numerical data type, e.g. Integer, Single, Double.

Remarks

Returns the absolute value (i.e. the magnitude) of any numerical expression. That is, if the expression has a value greater than or equal to zero, its value is returned unchanged. If the expression value is negative, it is negated and returned as a positive value.

Examples

Dim value As Single
value = Math.Abs(-1.23) ' Sets value to 1.23
value = Math.Abs(0) ' Sets value to 0
value = Math.Abs(3) ' Sets value to 3

See Also

Math Class