?
Solved

Passing an array to a VB dll from a VB app

Posted on 2003-10-22
6
Medium Priority
?
185 Views
Last Modified: 2010-05-03
Hello,
I have the following error with the code below.
Run-time error 13
Type Mismatch

'this code lies within a form on a vb appliation it calls a dll that was also created by vb
Private Sub vbAppSub()
 Dim array(1 to 5) as String  'note: if I change this line to variant I get rt error 381 Subscript out of range
 array(1) = "a"
 array(2) = "b"
 array(3) = "c"
 array(4) = "d"
 array(5) = "e"

 Dim objdll as object
 Set objdll = CreateObject("mydll.class")
 objdll.sendArray( array )                               'error is here
 set objdll = nothing

End Sub

///////////

'this code lies within a class module within a vb activeX dll
Public Function sendArray( passedArray() As Variant) As Boolean
 'code here in never executed
End Function


My question is how can I send arrays to dll's? what kinds of arrays can I send? what kinds of arrays can I not send?
Thanks
ff
0
Comment
Question by:funkyfinger
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 
LVL 2

Author Comment

by:funkyfinger
ID: 9603071
Substituting the following code in for the activeX dll has the same effect

Public Function sendArray(ParamArray passedArray()) As Boolean
 'code here never gets executed
End Sub
0
 
LVL 2

Author Comment

by:funkyfinger
ID: 9603090

I should say that substituting the following code has the same effect unless you change line 2 to
Dim array(1 to 5) as Variant
Then I no longer get the run time error 381 just the orgional error 13
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 9603415
What about:

Public Function sendArray(passedArray) As Boolean
'code
End Function
0
 
LVL 2

Author Comment

by:funkyfinger
ID: 9603608
I tried your code passing both a array of string and variant both resulted in

run-time error 381
subscript out of range

thks
ff
0
 
LVL 2

Accepted Solution

by:
funkyfinger earned 0 total points
ID: 9603776
I found the solution......
The two varibles here were the type of array I was sending and the parameters the function from the dll was expecting

this (from line 2) will work with the following code in the dll
2:
   Dim array(1 to 5) as Variant

dll:
Public Function sendArray(passedArray As Variant) As Boolean
 'code
End Function

 -- OR --

this (from line 2) will work with the following code in the dll
2:
   Dim array(1 to 5) as String

dll:
Public Function sendArray(passedArray() As String) As Boolean
 'code
End Function


Hope that this may help someone with a similar problem in the future.
ff
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month9 days, 18 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question