Abs Function

 

Abs (number)

 

Returns the absolute value of a number.

 

The data type of the return value is the same as that of the number argument.  However, if the number argument is a Variant of VarType (String) and can be converted to a number, the return value will be a Variant of VarType (Double).  If the numeric expression results in a Null, _Abs returns a Null.

 

Example:

 

Sub Main

 

   Dim Msg, X, Y

 

   X = InputBox("Enter a Number:")

   Y = Abs(X)

 

   Msg = "The number you entered is "  & X

   Msg = Msg + ". The Absolute value of " & X & " is " & Y

   MsgBox Msg 'Display Message.

  

End Sub