If you want to have the VB array (a to b) in i-th dimension bounds, you should initialize the SABounds[i].lLbound = a; and SABounds[i].cElements = b-a+1; As a rule, a is equal 0, so cElements = b-0+1 and = b+1. But RecordCount is equal to size of array (cElements), therefore, you haven't to add extra "1". Your array in VB will have (0 to x-1) bounds.
// Setup/Create our SAFEARRAY
SAFEARRAYBOUND SABounds[2];
SABounds[0].cElements = (DWORD)pRsHPASReports->RecordCount;
SABounds[0].lLbound = 0;
SABounds[1].cElements = 2; // You have only [0] and [1] in this dimension. Ok?
SABounds[1].lLbound = 0;
// Initialize the variant and set it up as an array of variants
VariantInit(pReportTypes);
pReportTypes->vt = VT_VARIANT | VT_ARRAY;
pReportTypes->parray = SafeArrayCreate(VT_VARIANT, 2, SABounds);
lLoop = 0; // SABounds[0].lLbound
while(! pRsHPASReports->IsEOF)
{
ldimension[0] = lLoop++;
ldimension[1] = 0; // SABounds[1].lLbound
CComVariant bstrTmp( pRsHPASReports->Fields->Item\["RptType"\]->Value );
TESTHR(SafeArrayPutElement( pReportTypes->parray, ldimension, &bstrTmp ));
ldimension\[1\]++;
CComVariant bstrTmp2( pRsHPASReports->Fields->Item\["Title"\]->Value );
TESTHR(SafeArrayPutElement( pReportTypes->parray, ldimension, &bstrTmp2 ));
pRsHPASReports->MoveNext();
}
With best wishes, Vita