enums

M

martin

Hi,

Is it possible to declare an enum and then declare a variable of the enum
type.


Public Class SessionVars
Inherits Object
Public Shared strGroupName As String
Public Shared strPracticeName As String
Public Shared mode As Modes
<------------------------------*******ERROR*******

Public Sub New()
MyBase.new()
End Sub

Protected Enum Modes As Integer
ModeAdd = 1
ModeEdit = 2
ModeView = 3
End Enum
End Class

I would like to be able to write in code

SessionVars.mode = Modes ModeAdd --and have intellisense pop the modes
up for me.

can anybody help me out or point me in the correct direction???

any help is appreciated.

cheers

martin.
 
J

Joe Fallon

Not sure how Shared variables change things, but this works:

Public Class Foo
Private mModes As Modes

Public Property MyMode() As Modes
Get
Return mModes
End Get
Set(ByVal Value As Modes)
mModes = Value
End Set
End Property

Public Sub Some Method
If MyMode= Modes.Add Then
etc.
End Sub

'remove extra Mode from "ModeAdd", etc.
Protected Enum Modes As Integer
Add = 1
Edit = 2
View = 3
End Enum

End Class
 
B

Brian W

Of course it's an error! Seems like common sense to me.

If your enum is a protected within SessionVars and you declare a public
variable of type Modes, how is the outside world supposed to know what Modes
is?
 

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

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top