Enumeration as Argument for Method

I have an enumeration:

Public Enum bbMenuItemTypes StandardMenuItem ForwardNavigation BackNavigation

and want to use a bbMenuItemTypes as an argument for my method. I am trying:

[code]Sub AddMenuItem(Caption as String, Key as String, Style as bbMenuItemTypes)

End Sub[/code]

But on compiling it is saying This type is private and can only be used within its module

All items in the enum are set to public and the enumeration is within a container control. I am then creating an instance of the container control on my window and trying to call the method above.

Any ideas would be appreciated.

Make it global

But it needs to be within the container control. How do I make it global?

…, Style As TheContainerControl.bbMenuItemTypes)

I seem to recall there were some issues with this, even if you do make it global… I got into the habit of putting enums in modules (often protected) so that they could be used elsewhere.

Forgive me for reviving a topic that has lain dormant for six years, but it seems to me to be close to a topic that’s troubling me.

As a result of adopting API 2.0 icons are now a MessageDialog.IconTypes enumeration. In API 1.0 they were Integers. Previously I could call a Message using an Integer type to specify the icon which was required. The call would be to the Method as ShowMessage(Message, Explanation, Icon, ActionButtonCaption). Instead of using raw numbers for Icon, I added a list of integer Constants, such as kCaution = 1 to the Messages module.

With API 2.0 I thought it would be easy to substitute the enum value in place of the constant, but I have yet to discover a way thru. For now I’m still using a list of integer constants in the definition of the Class (instead of a module), and in the definition of the Method I’m using a Select Case to convert the integers to the appropriate MessageDialog.IconType. It’s a bit long-winded, but it works.

Is it possible to pass an enum to a method directly?

Yes. Quite often you have to use the fully qualified namespace, like myclass.myenumeration.
If the enumeration values are the same as your constants or can be translated easily, you can also typecast the enumeration from the integers.