Syntax |
Abs(expression) |
Description |
Returns the absolute value of expression. |
Comments |
If expression is Null, then Null is returned. Empty is treated as 0. The type of the result is the same as that of expression, with the following exceptions: If expression is an Integer that overflows its legal range, then the result is returned as a Long. This only occurs with the largest negative Integer: Dim a As Variant Dim i As Integer If expression is a Long that overflows its legal range, then the result is returned as a Double. This only occurs with the largest negative Long: Dim a As Variant Dim l As Long If expression is a Currency value that overflows its legal range, an overflow error is generated. |
Example |
This example assigns absolute values to variables of four types and displays the result. Sub Main() s1% = Abs(-10.55) |
See Also |
Sgn (function). |
A |