473,811 Members | 2,979 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Visua lBasic.Collecti on
End Interface

Public Class HSTCradleData
Implements IHSTCradleData

Function Fetch(ByVal intFacility As Integer, _
ByVal intMonth As Integer, _
ByVal intYear As Integer) _
As Microsoft.Visua lBasic.Collecti on _
Implements IHSTCradleData. Fetch

Return New Collection
End Function
End Class
VB6
Dim x As New HSTCradleData.H STCradleData
Dim c As Collection
Set c = x.Fetch(txtFacC ode.Text, txtMonth.Text, txtYear.Text)
MsgBox c.Count
Nov 21 '05 #1
2 1947
Hi,

The vb.net collection is not the same as the vb6 collection.
Microsoft.Visua lBasic.Collecti on is the same as the vb6 collection

Ken

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

"Jacques Wentworth" <Ja*****@Health Systems.co.za> wrote in message
news:uz******** ******@tk2msftn gp13.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.Visua lBasic.Collecti on
End Interface

Public Class HSTCradleData
Implements IHSTCradleData

Function Fetch(ByVal intFacility As Integer, _
ByVal intMonth As Integer, _
ByVal intYear As Integer) _
As Microsoft.Visua lBasic.Collecti on _
Implements IHSTCradleData. Fetch

Return New Collection
End Function
End Class
VB6
Dim x As New HSTCradleData.H STCradleData
Dim c As Collection
Set c = x.Fetch(txtFacC ode.Text, txtMonth.Text, txtYear.Text)
MsgBox c.Count
Nov 21 '05 #2
In message <uz************ **@tk2msftngp13 .phx.gbl>, Jacques Wentworth
<Ja*****@Health Systems.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.Visua lBasic.Collecti on
End Interface

Public Class HSTCradleData
Implements IHSTCradleData

Function Fetch(ByVal intFacility As Integer, _
ByVal intMonth As Integer, _
ByVal intYear As Integer) _
As Microsoft.Visua lBasic.Collecti on _
Implements IHSTCradleData. Fetch

Return New Collection
End Function
End Class
VB6
Dim x As New HSTCradleData.H STCradleData
Dim c As Collection
Set c = x.Fetch(txtFacC ode.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********@NOSP AMzadsoft.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
14962
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) { document.images.src = eval("mt" +menu+ ".src") } alert("imgOff_hidemenu"); hideMenu=setTimeout('Hide(menu,num)',500);
12
2811
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 function descriptors for the overloaded functions of that name. A function descriptor would contain the address of the function to be called, and a description of the parameters that it must take. b. A list of parameters. This would be compared to the...
39
7685
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 indicate: a) That I don't know enough b) Passing arguments by ref is bad
1
1372
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, for people to be able to enter multiple "To:" "CC:" and "BCC:" I have only done the "To:" field as yes, Atrax gave me the hint on how to split the emails with a ";" using split
1
2953
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: Dim objColl As New VBA.CollectionClass() I get the following error: An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in WindowsApplication4.exe
13
2525
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 Error GoTo err_zoom strFormName = formName
1
5151
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 the collection object that is being passed from VB.Net to VB6 is giving me a "type mismatch" error when assigned to a collection variable in vb6. The collection in VB.Net is Microsoft.VisualBasic.Collection, so I do not see why this is causing any...
2
4280
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 Property1 As String Public Property2 As Integer Public Property myCollection1 As Arraylist (Actually, it will be a strongly
2
6732
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 a solution for that.
0
9724
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10644
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10127
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9201
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6882
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5552
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3863
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.