By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,699 Members | 1,372 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,699 IT Pros & Developers. It's quick & easy.

Passing Collection from .net to VB6

P: n/a
Hi

I'm trying to pass a collection from a .NET DLL to a VB6 app. I get a
error 13 (type mismatch) when I do so. I passed back a boolean variable
without any problems, but when I try the collection I get the error.

As you can see the function does not do anything at the moment, so it
must be some issue passing the collection.

Thanks

..NET
Public Interface IHSTCradleData
'Function Fetch(ByVal intFacility As Integer, _
' ByVal intMonth As Integer, _
' ByVal intYear As Integer) As Boolean
Function Fetch(ByVal intFacility As Integer, _
ByVal intMonth As Integer, _
ByVal intYear As Integer) _
As Microsoft.VisualBasic.Collection
End Interface

Public Class HSTCradleData
Implements IHSTCradleData

Function Fetch(ByVal intFacility As Integer, _
ByVal intMonth As Integer, _
ByVal intYear As Integer) _
As Microsoft.VisualBasic.Collection _
Implements IHSTCradleData.Fetch

Return New Collection
End Function
End Class
VB6
Dim x As New HSTCradleData.HSTCradleData
Dim c As Collection
Set c = x.Fetch(txtFacCode.Text, txtMonth.Text, txtYear.Text)
MsgBox c.Count
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi,

The vb.net collection is not the same as the vb6 collection.
Microsoft.VisualBasic.Collection is the same as the vb6 collection

Ken

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

"Jacques Wentworth" <Ja*****@HealthSystems.co.za> wrote in message
news:uz**************@tk2msftngp13.phx.gbl...
Hi

I'm trying to pass a collection from a .NET DLL to a VB6 app. I get a
error 13 (type mismatch) when I do so. I passed back a boolean variable
without any problems, but when I try the collection I get the error.

As you can see the function does not do anything at the moment, so it
must be some issue passing the collection.

Thanks

..NET
Public Interface IHSTCradleData
'Function Fetch(ByVal intFacility As Integer, _
' ByVal intMonth As Integer, _
' ByVal intYear As Integer) As Boolean
Function Fetch(ByVal intFacility As Integer, _
ByVal intMonth As Integer, _
ByVal intYear As Integer) _
As Microsoft.VisualBasic.Collection
End Interface

Public Class HSTCradleData
Implements IHSTCradleData

Function Fetch(ByVal intFacility As Integer, _
ByVal intMonth As Integer, _
ByVal intYear As Integer) _
As Microsoft.VisualBasic.Collection _
Implements IHSTCradleData.Fetch

Return New Collection
End Function
End Class
VB6
Dim x As New HSTCradleData.HSTCradleData
Dim c As Collection
Set c = x.Fetch(txtFacCode.Text, txtMonth.Text, txtYear.Text)
MsgBox c.Count
Nov 21 '05 #2

P: n/a
In message <uz**************@tk2msftngp13.phx.gbl>, Jacques Wentworth
<Ja*****@HealthSystems.co.za> writes
Hi

I'm trying to pass a collection from a .NET DLL to a VB6 app. I get a
error 13 (type mismatch) when I do so. I passed back a boolean variable
without any problems, but when I try the collection I get the error.

As you can see the function does not do anything at the moment, so it
must be some issue passing the collection.

Thanks

.NET
Public Interface IHSTCradleData
'Function Fetch(ByVal intFacility As Integer, _
' ByVal intMonth As Integer, _
' ByVal intYear As Integer) As Boolean
Function Fetch(ByVal intFacility As Integer, _
ByVal intMonth As Integer, _
ByVal intYear As Integer) _
As Microsoft.VisualBasic.Collection
End Interface

Public Class HSTCradleData
Implements IHSTCradleData

Function Fetch(ByVal intFacility As Integer, _
ByVal intMonth As Integer, _
ByVal intYear As Integer) _
As Microsoft.VisualBasic.Collection _
Implements IHSTCradleData.Fetch

Return New Collection
End Function
End Class
VB6
Dim x As New HSTCradleData.HSTCradleData
Dim c As Collection
Set c = x.Fetch(txtFacCode.Text, txtMonth.Text, txtYear.Text)
MsgBox c.Count


Not sure if this will help but:-

1. Your Fetch method takes Integer parameters and you are passing
string data. Use CLng function in VB6 to cast the string (ie: Integers
in .Net are Longs in VB6).

2. Your Fetch method declares the parameters as ByVal when the default
in VB6 is ByRef and again you are NOT casting the strings (ie: add ByVal
to the VB6 call).

Kind Regards,
--
Andrew D. Newbould E-Mail: ne********@NOSPAMzadsoft.com

ZAD Software Systems Web : www.zadsoft.com
Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.