How to use enumerations defined within Session

Hello happy fellows,

I have an enumeration named ‘foo’ defined in Session with an item ‘bar’ and the following code:

Dim t As Session.foo t = Session.foo.bar

The compiler raises the error ‘This Item does not exist’ for the second line. I guess it’s because’Session’ is here the instance of the class, not the name of the class. Still, the compiler doesn’t blink on the first line. Why is that?

Session’s are a little bit of magic. I’d suggest putting your enums into Modules.

They lack a bit of magic to prevent the developer to create Enumerations he/she won’t be able to use… :wink:

That’s what I’ve done when I remembered that I don’t use Enumerations in ‘App’ for the same reason. Thanks.

The first line it recognizes session.foo as a TYPE (because it has to be a type)

But in the second line session could be a function call (since there is a function called Session) OR a type and the compiler guesses the wrong one and tries to use the function “Session” which does not return anything that has a foo method.

In the case of App app it is, in the IDE the name of the class.
But at runtime it is also a function that returns the singleton for your app.
Rename “App” in the IDE to “myApp” and then you refer to app for the type but any time you need to get a reference to the singleton you use “App”.

Does this work with Session? Or will the magic Greg was talking about turn into a developer’s curse? :confused:

Not sure about Session.
To be honest I’d put them in a module, SessionSupport maybe, and use them that way.