Click here to Skip to main content
15,917,059 members

Comments by Revati513 (Top 2 by date)

Revati513 25-Jan-16 4:08am View    
Hello Xaver,

Thank you for the suggestion. We changed the .ODL, .CPP, .H files signature of TestFunc to accept the value of Param2 as reference.

C++:

.ODL:

long TestFunc(long* Param1, VARIANT* Param2, long Param3);

.CPP:

long TestFunc(long FAR* Param1, VARIANT* Param2, long Param3)
{
...
}

DISP_FUNCTION(Ctrl, "TestFunc", TestFunc, VT_I4, VTS_PI4 VTS_PVARIANT VTS_I4)

.H:

afx_msg long TestFunc(long FAR* Param1, VARIANT* Param2, long Param3);

#define VTS_PVARIANT "\x4C" // a 'VARIANT*'

VB.NET:

Function declaration:
Public Overridable Function TestFunc(ByRef Param1 As Integer, ByRef Param2 As Object, Param3 As Integer) As Integer

Param2 declaration inside a user defined structure in vb.net:
Dim Param2() As Byte

Function call:
result = TestFunc(Param1, Param2, Param3)

The function declaration in VB.NET now shows ByRef for Param2.

However, when TestFunc function is called in VB.NET following error occurs:

"Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))"

Thanks.
Revati513 21-Jan-16 4:38am View    
Hello Xaver,

Thank you for the quick response.
The VB.NET definition for TestFunc call is as below:

Public Overridable Function TestFunc(ByRef Param1 As Integer, Param2 As Object, Param3 As Integer) As Integer

We changed the type of Param2 to VARIANT* in below function signature of .odl file.
This changed the VB.NET definition of Param2 to ByRef. However when TestFunc function was called in Vb.net, type mismatch error occurred.

Function signature in .ODL file:
long TestFunc(long* Param1, VARIANT Param2, long Param3)

Thanks.