title: Using a VBA class to calculate the density of humid air at a given temperature and relative humidity
body: <p>I'm trying to use a class module to perform some calculations using a small number of inputs and then return the result of those calculations.</p>
  
  <p>I've never used classes before and I'm getting a 'Compile Error' (Invalid Outside Procedure).</p>
  
  <p>Here's the class module (CDensityHumidAir) code:</p>
  
  <pre><code>Private pSaturationPressureWaterVapour As Double
  Private pEso As Double
  Private pP As Double
  Private pC0 As Double
  Private pC1 As Double
  Private pC2 As Double
  Private pC3 As Double
  Private pC4 As Double
  Private pC5 As Double
  Private pC6 As Double
  Private pC7 As Double
  Private pC8 As Double
  Private pC9 As Double
  Private pPartialPressureWaterVapour As Double
  Private pPartialPressureDryAir As Double
  Private pDensityHumidAir As Double
  Private pAmbientAirTempCelsius As Double
  Private pAmbientAirTempKelvin As Double
  Private pRelativeHumidity As Double
  Private pBarometricPressure_hPa As Double
  Private pBarometricPressure_Pa As Double
  Private pGasConstantWaterVapour As Double
  Private pGasConstantDryAir As Double
  
  
  Public Sub CalculateDensityHumidAir()
  
  pAmbientAirTempCelsius = 15 'Input
  pAmbientAirTempKelvin = 273.15 + pAmbientAirTempCelsius
  pRelativeHumity = 0.5 'Input
  pBarometricPressure_hPa = 1029 'Input
  pBarometricPressure_Pa = pBarometricPressure_hPa * 100
  pEso = 6.1078
  pGasConstantWaterVapour = 461.495
  pGasConstantDryAir = 287.05
  pC0 = 0.99999683
  pC1 = -0.90826951 * 10 ^ -2
  pC2 = 0.78736169 * 10 ^ -4
  pC3 = -0.61117958 * 10 ^ -6
  pC4 = 0.43884187 * 10 ^ -8
  pC5 = -0.29883885 * 10 ^ -10
  pC6 = 0.21874425 * 10 ^ -12
  pC7 = -0.17892321 * 10 ^ -14
  pC8 = 0.11112018 * 10 ^ -16
  pC9 = -0.30994571 * 10 ^ -19
  pC0_T = pC0 + pAmbientAirTempCelsius
  pC1_T = pC1 + pAmbientAirTempCelsius
  pC2_T = pC2 + pAmbientAirTempCelsius
  pC3_T = pC3 + pAmbientAirTempCelsius
  pC4_T = pC4 + pAmbientAirTempCelsius
  pC5_T = pC5 + pAmbientAirTempCelsius
  pC6_T = pC6 + pAmbientAirTempCelsius
  pC7_T = pC7 + pAmbientAirTempCelsius
  pC8_T = pC8 + pAmbientAirTempCelsius
  
  pP = (pC0_T * (pC1_T * (pC2_T * (pC3_T * (pC4_T * (pC5_T * (pC6_T * (pC7_T * (pC8_T * (pC9))))))))))
  
  pSaturationPressureWaterVapour = pEso / (pP ^ 8)
  
  pPartialPressureWaterVapour = pRelativeHumidity * pSaturationPressureWaterVapour * 100
  
  pPartialPressureDryAir = pBarometricPressure_Pa - pPartialPressureWaterVapour
  
  pDensityHumidAir = pPartialPressureDryAir / (pGasConstantDryAir * pAmbientAirTempKelvin) + pPartialPressureWaterVapour / (pGasConstantWaterVapour * pAmbientAirTempKelvin)
  
  End Sub
  
  'AmbientAirTemperature Property
  Public Property Get AmbientAirTemperature()
      AmbientAirTemperature = pAmbientAirTempCelsius
  End Property
  Public Property Let AmbientAirTempertaure(Value As Double)
      pAmbientAirTemperature = Value
  End Property
  
  'RelativeHumidity Property
  Public Property Get RelativeHumidity()
      RelativeHumidity = pRelativeHumidity
  End Property
  Public Property Let RelativeHumidity(Value As Double)
      pRelativeHumidity = Value
  End Property
  
  'BarometricPressure Property
  Public Property Get BarometricPressure()
      BarometricPressure = pBarometricPressure_hPa
  End Property
  Public Property Let BarometricPressure(Value As Double)
      pBarometricPressure_hPa = Value
  End Property
  
  'DensityHumidAir Property
  Public Property Get DensityHumidAir()
      DensityHumidAir = pDensityHumidAir
  End Property
  </code></pre>
  
  <p>This is the code in the module where I'm trying to set the input variables and print the result to the immediate window.</p>
  
  <pre><code>Dim DensityHumidAir As CDensityHumidAir
  Set Tmp = New CDensityHumidAir
  Tmp.AmbientAirTemperature = 15
  Tmp.RelativeHumity = 0.5
  Tmp.Barometric.Pressure = 1000
  Debug.Print Tmp.DensityHumidAir
  </code></pre>
  
  <p>I've tried looking up the error message but it seems to suggest something hasn't been declared but I can tell what it is. To be frank, I'd be surprised if that was the only issue. I suspect once that's solved, I'll get some more error messages. What have I done wrong?</p>