<-- Previous || Up || Next -->

Divide Equal Sub
Basic Extensions Class

Public Sub DivideEqual( _
      ByRef rLeft As Variant _
    , ByVal vRight As Variant _
    )

"Divide Equals" or "Assign Division"
Divide rLeft by vRight and assign the result back into rLeft.
Similar to the C language "/=" operator.

Summary: This function is usually faster than the macroized eqivalent ("rLeft = rLeft / vRight") if rLeft is not a simple variable. This is because rLeft is passed-by-reference so that Visual Basic must only evaluate its address once.
Example #1 (valid example):
    Assuming
       Dim dblValue As Double
       dblValue = 2.5
    for example
       DivideEqual dblValue, 2
    leaves
       dblValue = 1.25
Example #2: (bad example; has no effect; see below)
    Assuming
       Dim dblValue As Double
       dblValue = 2.5
    for example
       DivideEqual (dblValue), 2
    leaves
       dblValue = 2.5
See also:
    DivideEqualFn Function
    DivideOnErrRtnZero Function
    Div Function
    TimesEqual Subroutine
    PlusEqual Subroutine
    MinusEqual Subroutine
Definition (Visual Basic):
    rLeft = rLeft / vRight
Definition (C):
    rLeft /= vRight;
rLeft: Numeric or date value which is divided by vRight. The result of the division is assigned back into the variable passed via rLeft, unless that value happens to be passed-by-value as in example #2.
vRight: The numeric value by which rLeft is divided.
Note: We would NOT use this subroutine to replace something like "dblValue = dblValue / 2", but we WOULD use it to replace something like "adblMatrix(intColumn, intRow, intItem) = adblMatrix(intColumn, intRow, intItem) / 2", especially since we only have to mention the "adblMatrix(intColumn, intRow, intItem)" part once.

Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.