How to pass value as dynamic array from vb to c

I have an ad below:

Type routineStruct man As String * 3 number As String * 5 End Type Type vbToC sch As String * 4 routine(0 To 10000) As routineStruct End Type vbfun As vbToC 

Now we send this vbfun As vbToC from VB to C. Now for the above type of vbToC, a 64K memory limit error occurs during compilation. So we use a dynamic array, as if -

 Type vbToC sch As String * 4 routine() As routineStruct End Type 

And then assign the value

 Redim routine(10000) For loop = 0 To 10000 .routine(loop).man = value1 .routine(loop).number = value2 Next 

My question above is the vbToc declaration for dynamic array is correct or not? if it is correct, is it possible to send values ​​from vb to c with this dynamic array and how to get the value for a dynamic array for each element of the structure?

+4
source share
1 answer

In VB6, the type you defined as "routStruct" is not valid. You would probably get a compilation error. If you are trying to declare "person" and "number" as arrays, the syntax is incorrect. You will need to use a declaration similar to your "regular" element with an array declaration.

In addition, you declared your type without an access modifier. When you do this, it will be "private" by default. If you exported the VB6 ActiveX DLL to a type library for use in C ++, the type would not be visible, and marshaling would not be possible.

The solution is to configure the type declaration to include the correct VB6 syntax, as well as make the type publication public. Marching native string types becomes BSTR in C / C ++, and there should be no problem.

0
source

All Articles