Making an Enum gloabl

C

Chad

In VB6, Enums that I declare within a class as PUBLIC are know outside of this class. In otehr words, the enum is global and may be referenced outside of the class in which it is declared.

In VB.Net, a Public enum is local to the class in which it is declared or instances of the class or classes that inherit from the class in which the Enum declaration resides.
 
A

Armin Zingler

Chad said:
In VB6, Enums that I declare within a class as PUBLIC are know
outside of this class. In otehr words, the enum is global and may be
referenced outside of the class in which it is declared.

In VB.Net, a Public enum is local to the class in which it is
declared or instances of the class or classes that inherit from the
class in which the Enum declaration resides.

Use
Classname.Enumname
or
import the class
or
declare the Enum outside a class.


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
S

Sapporo

This will also make your enum global

Public Module modDeclarations
Public Enum MyEnum
enumval01
enumval02
End Enum
End Module

In VB6, Enums that I declare within a class as PUBLIC are know outside of
this class. In otehr words, the enum is global and may be referenced outside
of the class in which it is declared.

In VB.Net, a Public enum is local to the class in which it is declared or
instances of the class or classes that inherit from the class in which the
Enum declaration resides.
 
J

Jay B. Harlow [MVP - Outlook]

Sapporo,
I tend to prefer:
Public Enum MyEnum
enumval01
enumval02
End Enum
Public Module modDeclarations
End Module

As the module is NOT needed to hold the Enum declaration. Enum declarations
can exist at the Namespace level just like Class, Module, Interface, and
Delegate.

Hope this helps
Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top