Hi
I am upgrading some VB 6 programs to VB 2005. These programs pass data to a C++ DLL and I am having trouble passing an array of strings.
The DLL looks basically like:
int _stdcall PassInStrings(short idx, LPSAFEARRAY FAR *strArrayPtr)
{
BSTR *tmpStrArray;
tmpStrArray = (BSTR*)(*tagArrayPtr)->pvData;for (i=0; i<idx; i++)
{
MyDebugPrint("PassInStrings", LPSTR(tmpStrArray[i+1]));
}
//other stuff
}
Calling this function from VB6 works nicely
Public Declare Function PassInStrings Lib "MyDLL.dll" (ByVal idx As Integer, ByRef lpStrArray() As String) as Integer
public sub sendStrings()
Dim iret as integer
Dim iCtr as Integer
dim myStr(4) as stringiCtr = 4
myStr(1)="Test String 1"
myStr(2)="Test String 2"
myStr(3)="Test String 3"
myStr(4)="Test String 4"iret = PassInStrings(iCtr, myStr)
End Sub
Calling the function from VB2005 does not work - An AccessViolationException is trapped.
Public Declare Function PassInStrings Lib "MyDLL.dll" (ByVal idx As short, ByRef lpStrArray() As String) as Integer
public sub sendStrings()
Dim iret as integer
Dim iCtr as Short
dim myStr(4) as stringiCtr = 4
myStr(1)="Test String 1"
myStr(2)="Test String 2"
myStr(3)="Test String 3"
myStr(4)="Test String 4"iret = PassInStrings(iCtr, myStr)
End Sub
As I prefer not to modify the DLL (it does a lot more than list a few strings) can anyone tell me what I must change in the VB 2005 code.
Thanks in advance
Rob