Sub Math Reals Class

Set1stIfNeg2ndIfPos

"Set First If Negative Or Set Second If Positive" Subroutine assigns positive values to one of the arguments. Subroutine assigns ( Absolute value of) negative values to the other argument.

Signature (Visual Basic / VBA)

Public Sub Set1stIfNeg2ndIfPos( _
      ByVal vExpr As Variant _
    , ByRef rSetIfNeg As Variant _
    , ByRef rSetIfPos As Variant _
    )

Code Example

    Assuming
       Dim varNeg As Variant
       Dim varPos As Variant
    for example
       Set1stIfNeg2ndIsPos 45, varNeg, varPos
    leaves
       varNeg = 0
       varPos = 45
    Also
       Set1stIfNeg2ndIsPos -45, varNeg, varPos
    leaves
       varNeg = 45
       varPos = 0

Parameters

Parameter Description
vExpr The number whose absolute value is assigned to one of the two other arguments, depending upon whether this number is positive or negative. Subroutine silently does nothing if vExpr is Null or cannot be fixed up to a number.
rSetIfNeg Argument which receives the absolute value of vExpr if vExpr is negative. This should be a numeric or Variant argument.
rSetIfPos Argument which receives the value vExpr if vExpr is positive. This should be a numeric or Variant argument.