Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB Code: dSelfCdArr is my array of double values

VB
Public Sub FilterDocTypeByPriv(colEventSets As Collection)

Dim lCount As Long
Dim oColItem As Object
Dim objDBEventSetRow As DB_EventSetRow
Dim evYes As Boolean
Dim dSelfCdArr() As Double
For lCount = 1 To colEventSets.Count
    Set objDBEventSetRow = colEventSets(lCount)
    ReDim Preserve dSelfCdArr(1 To lCount)
    dSelfCdArr(lCount) = CDbl(objDBEventSetRow.dSelf_cd)
Next

Call m_dtsAppForm.DocController.HasPrivCreateResultEventCode(m_dUserId, m_dPositionCd, m_dPPRCd, dSelfCdArr)
End Sub


C++ Idl file:

[id(51), helpstring("method HasPrivCreateResultEventCode")] HRESULT HasPrivCreateResultEventCode([in]double dUserId,[in]double dPosCd,[in]double dPPRCd, [in, out] VARIANT* pEventCode); 


C++ Code: I get bad pointers in the first line for VARIANT* pEventCode

STDMETHODIMP CDocumentController::HasPrivCreateResultEventCode(double dUserId,double dPosCd,double dPPRCd, VARIANT* pEventCode)
{   

HRESULT hr = E_FAIL;
AFX_MANAGE_STATE(AfxGetStaticModuleState())

if (V_VT(pEventCode) == (VT_ARRAY | VT_R8))
{
    CComSafeArray<double> arrECode;

    arrECode.Attach(pEventCode->parray);

    double pVals;

    int iCount = arrECode.GetCount();

    CMap<double,double,bool,bool> mapEventCds;

    for(int iIndex = 0; iIndex < iCount; iIndex++)
    {                              
        double pVals = arrECode.GetAt(iIndex);

        mapEventCds.SetAt(pVals, false);

        std::cout << "element " << iIndex << ": value = " << pVals << std::endl;
    }

    CheckPrivViewResultEventCds(dUserId, dPosCd, dPPRCd, mapEventCds);
                //pEventCode->c

    double      dEventCd(0.0);
    bool        bPriv(false);
    POSITION    pos(mapEventCds.GetStartPosition());
    INT_PTR     nEventCnt(mapEventCds.GetCount());

    CComSafeArray<double> pSafeArraypEventCode = NULL;
    for(INT_PTR count(0); count < nEventCnt; ++count)
    {
        mapEventCds.GetNextAssoc(pos, dEventCd, bPriv);     
        if (bPriv)
        {   
            pSafeArraypEventCode.Add(dEventCd);
        }
    }

    pEventCode->parray = pSafeArraypEventCode.Detach();
    // Empty the CMap
    mapEventCds.RemoveAll();

}
return S_OK;
}
Posted
Comments
Sergey Alexandrovich Kryukov 24-Oct-13 16:43pm    
What's wrong? The idea to torture yourself by VB6. :-)
—SA
Kenneth Haugland 24-Oct-13 16:52pm    
I'll say vb6 is nearly off-topic in Q&A, VB .NET is much better :-) I'll let this one pass though.
Sergey Alexandrovich Kryukov 24-Oct-13 16:59pm    
"Off-topic" is a pretty neat idea. :-)
As I always say, VB6 was obsolete even when it was first introduced to market, as decade or so earlier than that many technologies as infinitely more robust.
Of course, we can drive screws in using a hummer and even hit down nails using a screwdriver, but getting help on that... :-)
—SA
Kenneth Haugland 24-Oct-13 17:02pm    
I rather do assembly than vb6, I truly heated it too, infact I have nightmares about it still even though it has been nearly 15 years since I had it in school :-/
Sergey Alexandrovich Kryukov 24-Oct-13 18:16pm    
Thanks goodness we did not have anything like that at school, but the annoyance of suggestions to do that and, of course, legacy, is more than enough, but I never agreed. No wonder, VB6 got so much popularity. Such things always attracted certain category of people, by reasons similar to those bringing other people to fortune tellers or multi-level marketing (MLM) :-).
—SA

1 solution

You could have done with posting how you declared the function in VB and how VARIANT is defined in your C++.

However, have a look at this article http://support.microsoft.com/kb/207931[^]

Hopefully it's enough to get you going again.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900