Discussion:
Accessing Public Enums in VB6 DLL
(too old to reply)
Matt F
2003-10-13 10:42:21 UTC
Permalink
Hi all

I am using a VB6 COM object from a VB.Net web app. The VB6 class I am
accessing contains a number of public enums. The class Instancing
property is set to GlobalMultiUse and, in the original VB6 app, the
enums were called from other classes without the need for instantiation.

I have found that in order to access the class from VB.Net I have to
instantiate it, as the GlobalMultiUse setting doesn't translate. That
is fine but, even when I have an instance of the class, I still can't
access the enums. When I look at the VB6 class in the .Net Object
Browser, the enums don't appear.

I have read that public enums go into the type library in COM, but are
not considered members of the class. Does anyone know of any way to
access these enums?

Thanks in advance for any help anyone can give me.

Matt

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Patrick Steele [MVP]
2003-10-14 16:22:19 UTC
Permalink
In article <***@TK2MSFTNGP09.phx.gbl>, ***@devdex.com
says...
Post by Matt F
I have read that public enums go into the type library in COM, but are
not considered members of the class. Does anyone know of any way to
access these enums?
I did a simple example. I created a VB6 DLL containing only this class:

Option Explicit

Public Enum MessageType
Info = 1
Warning = 2
Error = 3
End Enum

Public Sub GetAStatus(mt As MessageType)
End Sub

I then used tlbimp.exe to create a RCW (runtime callable wrapper) around
the VB6 com DLL. I created a small VB.NET console app and added a
reference to the .NET RCW created with tlbimp. Here's the code (the
namespace "pubenum" came from the fact that I named the RCW
"pubenum.dll"):

Option Strict On
Option Explicit On

Imports System
Imports pubenum

Public Class Module1

Public Shared Sub Main()
Dim et As MessageType

Console.WriteLine(et.Info)

End Sub

End Class

I had no problems with the public MessageType enum. What problem are
you seeing?
--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
Matt F
2003-10-15 01:47:09 UTC
Permalink
Patrick

Thank-you very much for your reply. Unfortunately, I've made a boo boo,
and am seeing the enums after all. I had instantiated an instance of
the class where they are declared, and was looking for them there.
However, they appear directly under the assembly name. VB6 operates the
same way, I just hadn't realised it.

My apologies

Matt

PS At least I got to read the very interesting space shuttle software
article linked to on your blog. :)

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Loading...