473,406 Members | 2,849 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,406 software developers and data experts.

Problem passing Collection from VB.Net to VB6

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 trouble at all. Here is some example code
that causes the problem mentioned:

----------------------------
VB.Net Class:
----------------------------
<System.Runtime.InteropServices.ProgId("Marcus_Tes t.Class1"),
ComClass(Class1.ClassId, Class1.InterfaceId, Class1.EventsId)_
Public Class Class1

#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String =
"7E2FF7F3-8546-4987-AF5A-4A725211B807"
Public Const InterfaceId As String =
"7B84FBBA-4241-44fc-AD13-C988D75E5B5C"
Public Const EventsId As String =
"24672225-C20D-4020-ACA9-FDF5E494C5BC"
#End Region

Public Function GetCollection() As Microsoft.VisualBasic.Collection
Dim c As New Collection
c.Add("Hello")
c.Add("there")
c.Add("you")
Return c
End Function

End Class
------------------------------
VB6 Code that references it (with proper reference added in
'references' of course)
------------------------------
Private Sub Command1_Click()
Dim c As Collection
Dim myClass As New ClassLibrary1.Class1
Set c = myClass.GetCollection 'THIS LINES CAUSES "TYPE MISMATCH"
ERROR
End Sub
Any thoughts on why this error is occuring? How can I pass a
Microsoft.VisualBasic.Collection from .Net to vb6?

Thanks for any suggestions.

Marcus

Oct 13 '06 #1
1 5129
Holysmoke,

The only class that most regulars or others find it a pity that it is in the
VB namespace and not in the compatilbe namespace (which is temporaly) is the
vb.collection. It gives you only trouble.

Try to change it as soon as possible for a Net List or Collection class as
soon as possible.

As most things which have synonyms it is now almost impossible to find on
MSDN. You have first to strugle through things as foxpro etc. But try it.
Keywords to search are Ilist ICollection "Collection Class" "List Class"
"Generic list"

I hope this helps,

Cor
"holysmokes99" <ho**********@hotmail.comschreef in bericht
news:11*********************@k70g2000cwa.googlegro ups.com...
>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 trouble at all. Here is some example code
that causes the problem mentioned:

----------------------------
VB.Net Class:
----------------------------
<System.Runtime.InteropServices.ProgId("Marcus_Tes t.Class1"),
ComClass(Class1.ClassId, Class1.InterfaceId, Class1.EventsId)_
Public Class Class1

#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String =
"7E2FF7F3-8546-4987-AF5A-4A725211B807"
Public Const InterfaceId As String =
"7B84FBBA-4241-44fc-AD13-C988D75E5B5C"
Public Const EventsId As String =
"24672225-C20D-4020-ACA9-FDF5E494C5BC"
#End Region

Public Function GetCollection() As Microsoft.VisualBasic.Collection
Dim c As New Collection
c.Add("Hello")
c.Add("there")
c.Add("you")
Return c
End Function

End Class
------------------------------
VB6 Code that references it (with proper reference added in
'references' of course)
------------------------------
Private Sub Command1_Click()
Dim c As Collection
Dim myClass As New ClassLibrary1.Class1
Set c = myClass.GetCollection 'THIS LINES CAUSES "TYPE MISMATCH"
ERROR
End Sub
Any thoughts on why this error is occuring? How can I pass a
Microsoft.VisualBasic.Collection from .Net to vb6?

Thanks for any suggestions.

Marcus

Oct 13 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: DarthMacgyver | last post by:
Hello, I recently wrote a survey application. Each question is very similar. The first questions gives me a problem when there are multiple people taking the survey (The Database connection...
5
by: lugal | last post by:
This might be more appropriate here. I'm new to C++, coming from a background in another languages that allowed a similar solution to work (Python). I wrote the following code in C++ based on the...
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: ...
2
by: Jacques Wentworth | last post by:
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...
1
by: Spiro | last post by:
Hi all, i'm trying to make some user interface objects in python. I have classes XWindow and XMainWindow(XWindow) (XMainWindow inherited from XWindow) XWindow have all drawing functionality...
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...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
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,...

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.