473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Passing Collection from .net to VB6

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
2 1925
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
12
by: Joel | last post by:
Hi all, Forgive me if I've expressed the subject line ill. What I'm trying to do is to call a c++ function given the following: a. A function name. This would be used to fetch a list of...
39
by: Mike MacSween | last post by:
Just spent a happy 10 mins trying to understand a function I wrote sometime ago. Then remembered that arguments are passed by reference, by default. Does the fact that this slowed me down...
1
by: Hawk | last post by:
What I am doing is creating a web based email, using .net I have finised the inbox, read, delete email etc.. Im in the process of making the "create email" or compose... What the plan is,...
1
by: PJS | last post by:
I am trying to use a COM object which has a parameter of type Collection in VB6. .Net recognizes this collection as a VBA.Collection object. When I try creating a VBA.Collection in .Net using: ...
13
by: Deano | last post by:
Apparently you can only do this with one value i.e Call MyAssetLocationZoom(Me!txtLocation, "Amend data") This runs; Public Sub MyAssetLocationZoom(ctl As Control, formName As String) On...
1
by: holysmokes99 | last post by:
I have run the VB.Net upgrade wizard to get a vb6 project up to VB.Net 1.1. This is a class library that is referenced by another VB6 app. I have exposed it to for COM access. The problem is that...
2
by: =?Utf-8?B?Y3Nz?= | last post by:
I am new to ASP.net webservice and have a quesiton. Is is possible to pass custom object to a web service (using VB 2005)? My custom object will look like this Public Class Myclass Public...
2
by: Torsten Z | last post by:
Hi, I have tried several things to passing an array of objects or a Object Collection from .NET to VB6 but I can't get it work. Passing one object works fine, but more than one not. Has anybody...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.