Arrays in function argument list

VB6 is quite happy to let me declare a subroutine (in a STDCALL linked DLL) using Arrays in the argument list.  

What is less clear is how do I call a subroutine with arrays in the argument list?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

An example:

Private Sub Command1_Click()
    Dim cA(10) As Long
    cA(0) = 10
    ArrayInArg cA
End Sub

Private Function ArrayInArg(cArray() As Long)
    Debug.Print cArray(0)
End Function
The above code passes the array ByRef, so if you modify cA, cArray will also change.  You can make a local copy of cArray in ArrayInArg without modifying the original array:

Private Function ArrayInArg(cArray() As Long)
    Dim cArr 'Variant
    cArr = cArray() 'Copy of cArray
    cArr(0) = 5
    Debug.Print cArr(0)
End Function
griffittAuthor Commented:
Apologies Erick37 - I don't think my question was well wordeed :-)

Perhaps I should have given an example of what I am doing.

In the Module:

Public Declare Sub DoStuff Lib "stuff.dll" Alias "DOSTUFF" (ByRef mode As Integer, ByRef Level() As Double)

In the Form:
Dim mode as Integer
Dim Level(16) as Double

Call DoStuff(mode,Level)

This gives a type mismatch error for Level.  I can't see why it doesn't work!!
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

To pass an array to a DLL, or any other api, you should pass the adress of the first item in your array. This means:

Call doStuff (mode, Level(0))

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
griffittAuthor Commented:
Thanks Trillo - you were close enough to get the cigar ;-)

It actually turns out that you need to use:

Call doStuff (mode, Level())

with empty parenthesis!

The other problem that was catching me out was that in my 'genuine' code the subroutine is called using 34 arguments (most of which are arrays).  When I was defining these in my code each must be defined seperately. ie.

Dim A(10) as Double, B(10) as Double

rather than

Dim A(10),B(10) as Double

Don't ask me why!
Most DLLs which accept arrays declare it as a void *, and should be declared in VB with the Any type.

Public Declare Sub DoStuff Lib "stuff.dll" Alias "DOSTUFF" (ByRef mode As Integer, ByRef pLevel As Any)

Then you pass Level(0) to the pointer.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.