11-05-2012 03:47 AM
I'm now having problem to get output of Labview dll in Microsoft Excel VBA environment.
The labview dll function - Getstring below is the function I used in Excel VBA environment
/*!
* GetString
*/
void __stdcall GetString(double x, double y, char String[], int32_t len);
I declared the dll as below
Public Declare sub GetString Lib "Filelocation..." (Byval X as double, Byval Y as Double, Byval StringData as string, Byval length as integer)
then I called the function in the VBA as below
Dim result as string
GetString(10,10,result,4)
Msgbox("the result is " & result)
when I run the code above, the result I got was actually ?the result is" only, that means result has no value returned.
Could anyone help to share/advise what else I can do to get the value of the result?
11-05-2012 12:25 PM
I'm not intimately familiar with VB, but if you're expecting the LabVIEW DLL to fill in the string, then you need to pass it ByRef instead of ByValue, and you need to allocate enough space for that string. I'm assuming here that the len parameter is the string length, which you've set to 4, so you need to declare result as a string of at least 4 characters before passing it to the DLL.
11-05-2012 06:17 PM
Ya...I have tried to use byref, it cause MS Excel not responding.