LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

how to return a safe array/variant from a CVI DLL to visual basic?"

"I am trying to return a safe array from a CVI Dll to visual basic. I can successfully call CVI functions from VB and return simple types like int , double etc but when I try to return a Safe Array then the "generate visual basic module" gives me error.
The line that give error in the header file to generate the visual basic module is
LPSAFEARRAY* getAmplitudes() ;

and the function where i generate the safe array is
Amplitudes, iterations, safeArray are global variables


LPSAFEARRAY* getAmplitudes()
{
CA_Array1DToSafeArray (Amplitudes, CAVT_DOUBLE, iterations, safeArray);
return safeArray;
}"
0 Kudos
Message 1 of 2
(2,920 Views)
The CVI utility that creates VB bas modules is intended to be used on C instrument driver DLLs. So only basic datatypes (ANSI C) are supported.
However I'm curious to know if you are using a COM datatype because 1) you are creating an ActiveX server in CVI or 2) you need to use this array in VB.
If the latter is true, then I'd suggest you change the prototype of your function to use a C-style array instead of a COM array:

int getAmplitudes(double* array, int size);

Visual Basic should be able to handle the first parameter as an array. Let me know if you have trouble using this array in VB.

Regards,
Azucena
NI
0 Kudos
Message 2 of 2
(2,920 Views)