JOKER
asked on
return SAFEARRAY to VB
Hello
I have a DLL in C++ and a Visual basic (6) client
application.
I need to pass an empty vector of structures from the client
to the DLL, and return it full from the DLL.
I need that the client will declare the vector as "Vector()"
and the DLL function will return the number of
cells in the vector (the DLL function will fill the Vector).
The CLIENT part will look like this :
-------------------------- ---------- -
dim Ret as long
dim VecMadadim() as SomeStructure
Ret = RequestFunction(VecRequest (), nRecordCount)
for i=1 to Recordcount
print VecMadadim(i).Field1
print VecMadadim(i).Field2
print VecMadadim(i).Field3
next i
The DLL part will look like this :
-------------------------- ---------- -
int __stdcall RequestMadadim(SAFEARRAY** psaRequest, int* nRecordCount)
{
...
}
Thank you very much :)
I have a DLL in C++ and a Visual basic (6) client
application.
I need to pass an empty vector of structures from the client
to the DLL, and return it full from the DLL.
I need that the client will declare the vector as "Vector()"
and the DLL function will return the number of
cells in the vector (the DLL function will fill the Vector).
The CLIENT part will look like this :
--------------------------
dim Ret as long
dim VecMadadim() as SomeStructure
Ret = RequestFunction(VecRequest
for i=1 to Recordcount
print VecMadadim(i).Field1
print VecMadadim(i).Field2
print VecMadadim(i).Field3
next i
The DLL part will look like this :
--------------------------
int __stdcall RequestMadadim(SAFEARRAY**
{
...
}
Thank you very much :)
ASKER
jkr,
Thanks for this but,
this is not what I asked for,
I need that in VB i will decalre the array
like this - > "TheArray() as string"
NOT like this -> "TheArray(10) as string"
I need that the DLL will set the number of cells
in the array .
Thanks
Thanks for this but,
this is not what I asked for,
I need that in VB i will decalre the array
like this - > "TheArray() as string"
NOT like this -> "TheArray(10) as string"
I need that the DLL will set the number of cells
in the array .
Thanks
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
PAQ/Refund
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
Tinchos
EE Cleanup Volunteer
I will leave a recommendation in the Cleanup topic area that this question is:
PAQ/Refund
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
Tinchos
EE Cleanup Volunteer
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Basically, you would
int __stdcall RequestMadadim(SAFEARRAY**
{
HRESULT hr;
long lLBound, lUBound;
// Check dimensions of array
if (SafeArrayGetDim(*ppsa) != 1)
return ResultFromScode(E_INVALIDA
for ( long l = lLBound; l < lUBound; l++)
{
hr = SafeArrayPutElement(*ppsa,
if (FAILED(hr))
// handle error;
}
}