Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Passing an array to a VB dll from a VB app

Posted on 2003-10-22
6
Medium Priority
?
186 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

636 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