Is there a ubound for enums in VB9?

  • Thread starter Thread starter Just_a_fan
  • Start date Start date
J

Just_a_fan

Is there an equivalent of ubound for arrays for enum? I guess I could
create one by having a dummy name at the end. Just wondering... Tried
the help but, as many times, it was no help.

Thanks.
 
If en is declared to be of your Enum, then this will return the number of
values for the Enum:

Enum.GetNames(en.GetType()).GetLength(0)
 
Is there an equivalent of ubound for arrays for enum? I guess I could
create one by having a dummy name at the end. Just wondering... Tried
the help but, as many times, it was no help.

If you want to determine the maximum value (assuming the base type is
'Integer'):

\\\
MsgBox(GetMaximumValue(GetType(Test)))
....
Public Function GetMaximumValue(ByVal EnumType As Type) As Integer
Return Aggregate Value In [Enum].GetValues(EnumType) Into
Max(CInt(Value))
End Function
///
 
Back
Top