title: convert variant into COleSafeArray in MFC c++
body: <p>How can I put VARIANT into  COleSafeArray?
  I tried</p>
  
  <pre><code>Variant vara;
  COleSafeArray force= vara;
  </code></pre>
  
  <p>and got "debug assertion failed"</p>
  
  <p>I used a library to convert voltage value to Force value.
  In Library, there is below function:</p>
  
  <pre><code>VARIANT _Calibration::ConvertToFT(VARIANT* Voltages, LPCTSTR ForceUnits, LPCTSTR TorqueUnits)
  {
      VARIANT result;
      static BYTE parms[] =
          VTS_PVARIANT VTS_BSTR VTS_BSTR;
      InvokeHelper(0x60030040, DISPATCH_METHOD, VT_VARIANT, (void*)&amp;result, parms,
          Voltages, ForceUnits, TorqueUnits);
      return result;
  }
  </code></pre>
  
  <p>So in my main program:</p>
  
  <pre><code>COleSafeArray voltagesk;
  double voltages[6];
  _read-voltage(voltages);
  long y;
      for (y = 0; y&lt;6; y++) {
          // COleSafeArrays use pass-by-reference methods to read or write
          voltagesk.PutElement(&amp;y, &amp;(voltages[y]));
      }
  COleSafeArray forces = GetActiveCalibration().ConvertToFT(voltagesk, L"lb", L"in-lb");
  for (y = 0; y&lt;6; y++) {
          // COleSafeArrays use pass-by-reference methods to read or write
          forces.GetElement(&amp;y, &amp;(voltages[y]));
  </code></pre>
  
  <p>I tried deleting  this line"<code>COleSafeArray forces = GetActiveCalibration().ConvertToFT(voltagesk, L"lb", L"in-lb");</code>", my program ran well, but cannot convert voltage into force so I think that converting from VARIANT to COleSafeArray, has problem</p>