Abs Function
Devolve o valor absoluto dunha expresión numérica.
Sintaxe:
Abs (Número)
Valor de retorno:
Duplo
Parámetros:
Number: Any numeric expression that you want to return the absolute value for. Positive numbers, including 0, are returned unchanged, whereas negative numbers are converted to positive numbers.
O seguinte exemplo usa a función Abs para calcular a diferenza entre dous valores. Non importa que valor introduce primeiro.
Exemplo:
Sub ExampleDifference
Dim siW1 As Single
Dim siW2 As Single
siW1 = Int(InputBox("Introduza a primeira cantidade","Entrada de valor"))
siW2 = Int(InputBox("Introduza a segunda cantidade","Entrada de valor"))
Print "A diferenza é "; Abs(siW1 - siW2)
End Sub