Hi Raymond,
See it this helps:
<Flags()> _
Public Enum MyEnumWithFlags
A = 1
B = 2
End Enum
Public Enum MyEnumWithoutFlags
A = 1
B = 2
End Enum
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Call f(MyEnumWithFlags.A)
Call f(MyEnumWithoutFlags.A)
End Sub
Sub f(ByVal e As System.Enum)
Dim objType As Type
objType = e.GetType
If objType.GetCustomAttributes(GetType(FlagsAttribute ),
True).GetLength(0) > 0 Then
MsgBox("It has Flags attribute")
Else
MsgBox("It does not have Flags attribute")
End If
End Sub
--
Best regards,
Carlos J. Quintero
MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
"Ray Cassick (Home)" <rc************@enterprocity.com> escribió en el
mensaje news:Oe**************@TK2MSFTNGP12.phx.gbl...
I have a function that takes a value is as System.Enum and I want to be
able to look at that value and determine if it is a regular enum or an enum
that has a <Flag()> attribute set on it.
I am trying to write a wrapper function that takes an enum and an integer
value and validates if the value is actually part of the enum. Just trying
to use .IsDefined will not return accurate results (as far as I can find)
if the enum is a flag so if it is I want to jump to some other code and
try to validate another way.
I have been looking all over and can't find a way (probably using
reflection) to inspect this and look for any applied attributes.
--
Raymond R Cassick
CEO / CSA
Enterprocity Inc.
www.enterprocity.com
3380 Sheridan Drive, #143
Amherst, NY 14227
V: 716-316-5973
Blog: http://spaces.msn.com/members/rcassick/