title: Passing VBA Variable by reference to class function
body: <p>I have a custom class with various Get/Let properties</p>
  
  <pre><code>Property Get pGasIP() As Double
      pGasIP = zpGasIP
  End Property
  
  Property Let pGasIP(ByVal NewValue As Double)
      zpGasIP = NewValue
  End Property
  </code></pre>
  
  <p>Along with functions that reference these variables:</p>
  
  <pre><code>Public Sub CalcProduction(Index As Long, life As Double)
  
  zoGasProdStartGross = TypeCurve("cum", -Base + 1, pGasTimeRestricted, _
  pGasIP, pGasDi, pGasDiHyp, pGasBFactor, 0.06, pGasQab, pCurtailment)
  
  End Sub
  </code></pre>
  
  <p>I am trying to iterate on the variables within this function by passing a reference to the desired variable in a Breakeven function as follows (iterative variable refers to the class property that I would like to reference, ObjFunction refers to an output value that I would like to reference and change)</p>
  
  <pre><code>Public Sub Breakeven(ByRef iterativeVariable As Variant, ByRef ObjFunction as variant)
  Dim DesiredValue as Double, CurrentDistance as Double
  
  'set up incremental calculation
      IterativeVariable = IterativeVariable + .001
      CurrentDistance = DesiredValue - ObjFunction
  
  'calculate new value with incremented variable 
      CalcProduction 600, 600
      CurrentDistane = DesiredValue - ObjFunction
  </code></pre>
  
  <p>When I try to pass the object properties in a normal module, the values of the corresponding class properties are being passed rather than the reference.  Is there a way to pass object properties into a subroutine that can modify/calculate them?</p>
  
  <p>Thanks!</p>
  
  <p>Jordan  </p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I am trying to pass the following argument in a normal module:</p>
  
  <pre><code>Object.Breakeven Object.GasIP, Object.GasEUR
  </code></pre>
  
  <p>I want the actual references to the properties passed in (so I can modify them), but this nomenclature passes in the value of the properties instead.</p>