how do you return a value for an enum property type?

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

It should be simple, but I'm stuck on this one... how do you return a value for
an enum property type?

TIA,
Bob
 
Bob said:
It should be simple, but I'm stuck on this one... how do you return a
value for an enum property type?

I'm not sure if this is what you are looking for:

Property MyProp() As FormBorderStyle
Get
Return FormBorderStyle.None
End Get
Set(ByVal Value As FormBorderStyle)

End Set
End Property

(the example doesn't make sense but it shows...)
 
An example to clarify:

Public ReadOnly Property SomeEnum() As System.Enum
Get
'How do I return RandomEnum ???
End Get
End Property

Public Enum RandomEnum
member1
member2
End Enum

Bob
 
Bob said:
An example to clarify:

Public ReadOnly Property SomeEnum() As System.Enum
Get
'How do I return RandomEnum ???

I don't know whether I understand your problem:

Return RandomEnum.member1

End Get
End Property

Public Enum RandomEnum
member1
member2
End Enum


But, why don't you declare the property this way?

Public ReadOnly Property SomeEnum() As RandomEnum

This also enables intellisense after typing "return "
 
I don't want to return an Enum member. I want to return the Enum itself.

But I guess I'll be stuck with returning its type instead. Oh well.

Bob
 
Return RandomEnum.member1 will return 0
Return RandomEnum.member2 will return 1

You want to return the enum itself? You can refer to it's elements from the
class where you design it?
 
Bob said:
I don't want to return an Enum member. I want to return the Enum
itself.

But I guess I'll be stuck with returning its type instead. Oh
well.

The Enum itself *is* a type, so you can

Return GetType(RandomEnum)

and change the property type to "As System.Type"
 
Back
Top