If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Hybrid View

VB/C Array parameters

I have a function in C, that has already been written by other People and
now I have to write a .dll with this function, so that I can call it from
the VB 6.0.
The C-function declaration is as follows:

Public Type mw_MatInfoTyp
Lfdnr As Long
Matnr As String
Werk As String
Maktx As String
ValueMentorC As String
ValueF As Double
ValueVisulaC1 As String
ValueVisulaC2 As String
Status As String
Existenzkz As String
MessageType As String
MessageId As String
MessageNumber As Long
Message As String
MessageV1 As String
MessageV2 As String
MessageV3 As String
MessageV4 As String
End Type

Private Sub Command1_Click()
Dim i As Integer
ReDim x(50)
ReDim y(50)
For i = 0 To 10
x(i).FirstName = Text1.Text
x(i).MiddleName = Text2.Text
x(i).LastName = Text3.Text
Next
'I have also called the function with different input values in
each structure
mult x(), y()
End Sub

---------------------------------------

That has worked. With the debug, I can see that I got the right results,
at least when the array is small (size about 50). But when I close the VB-program
(when I'm using the VB-debug or running the executable file), an error ocurrs
(unallowed memory handling, or something like that - my Windows is not in
english -) and the program or the VB-studio shuts down.
When I use bigger arrays, the same error occurs already when call the function.
Then when I change:

void _stdcall mult(customer A[], customer B[]);

for :

void _stdcall mult(customer *A[], customer *B[]);

, because that is what I need in my program, that the same error occurs already
when call the function.

Is there any way of passing pointers of arrays of structures from the VB
to a function in a .dll wrutten in C????