I am using Excel VBA declaration of external function in cvirte.dll library. I have done declaration and calling successfully of these functions(LoadPanel,DisplayPanel,DiscardPanel,GetUserEvent,PlotStripChart,PlotStripChartPoint,ClearStripChart) and they works OK. But with SetCtrlVal() and all functions which have some argument of any data type I have trouble.
To function SetCtrlVal() I have done following steps, as shown bellow.
in C language the definition of function I need to call is as follows:
int SetCtrlVal (int Panel_Handle, int Control_ID, ...);
last argument can by of any data type.
in Excel VBA module my code is as follows:
Public Declare Function SetValue Lib "cvirte.dll" (ByV
al Panel_Handle As Integer, ByVal Control_ID As Integer, Value As Any) As Integer
How you can see, argument "value" I have declared as Any data type.
Compiling of the VBA code is OK, but when I call function in this code:
------------------------------------------------------
Public Declare Function SetValue Lib "cvirte.dll" (ByVal Panel_Handle As Integer, ByVal Control_ID As Integer, Value As Any) As Integer
Dim speed as Double
Dim ph as Integer
ph=SetCtrlVal(1, 8, speed)
'panel has handle=1
'control has id =8
following error occurs:
Run-time error :'49' Bad DLL calling convention
I think my function declaration is OK and I dont know where is a problem now, what is wrong. I think that problem is at 3-rd argument,but not sure. Do you now how to fix it ? I am using LabWindows/CVI 4.0.1.
Any help or suggestions would be greatly appreciated.