Solved

Passing an array to a VB dll from a VB app

Posted on 2003-10-22
6
178 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
  • 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

705 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now