F
Francogrex
Hi, I had asked this before but in a VB group they suggested I come
ask it here:
I can pass single strings between VBA and C (dll) without problem.
But now I am trying to pass an array of strings from VBA to a C file
(as a test) but that is not working at all maybe someone can give
hints. I'm using VBA for excel 2003 on winXP. Thanks.
The C file that is made into 'mydll.dll"
#include "windows.h"
#include "string.h"
#include "stdio.h"
#include "stdlib.h"
__declspec (dllexport) void __stdcall CFUN(LPSTR **pout)
{
FILE *in=fopen("c:/excel.txt","w");
int i;
for (i=0;i<4;i++)
{
fprintf(in, "%s\n", *(pout+i));
}
fclose(in);
}
The VBA code:
Private Declare Function CFUN& Lib "c:/mydll.dll" (ByRef pout As
String)
Sub TEST()
Dim pout(4) As String
pout(0) = "one"
pout(1) = "two"
pout(2) = "three"
pout(3) = "four"
CFUN (pout(0))
End Sub
The excel.txt file does not contains the strings
ask it here:
I can pass single strings between VBA and C (dll) without problem.
But now I am trying to pass an array of strings from VBA to a C file
(as a test) but that is not working at all maybe someone can give
hints. I'm using VBA for excel 2003 on winXP. Thanks.
The C file that is made into 'mydll.dll"
#include "windows.h"
#include "string.h"
#include "stdio.h"
#include "stdlib.h"
__declspec (dllexport) void __stdcall CFUN(LPSTR **pout)
{
FILE *in=fopen("c:/excel.txt","w");
int i;
for (i=0;i<4;i++)
{
fprintf(in, "%s\n", *(pout+i));
}
fclose(in);
}
The VBA code:
Private Declare Function CFUN& Lib "c:/mydll.dll" (ByRef pout As
String)
Sub TEST()
Dim pout(4) As String
pout(0) = "one"
pout(1) = "two"
pout(2) = "three"
pout(3) = "four"
CFUN (pout(0))
End Sub
The excel.txt file does not contains the strings