-
I've declared public enum at module level:
Code:
Public Enum XXX
....
End Enum
... and referenced in user control
Code:
Public Property XXXProperty() as XXX
...
End Property
I get the following error when compiled:
"Private Enum types cannot be used as parameter or return types for public procedures, or as public data members."
The declaration is not included in user control module because it'll be referenced in other user controls in the same project.
-
From what I understand this means you cannot use the Enum type as the return type from an exposed function if the Enumeration itself isn't exposed as well.
In this instance a user could reference your function but it has no idea what the values or even the definition of the Enum type that is used as the return value is because it cannot see your definition.
I would try and put the Enum definition outside of the control itself... possibly in a global module so that it can be seen by the calling program the same as it can internally.
Its all about encapsulation. Below might help you understand why... the Def Enum is only local to the control
Code:
INSIDE CONTROL OUTSIDE
+------------------------+
|Def Enum | X Cannot see Enum
| |
|Public Function as Enum |--->Sees Function
+------------------------+
Transform to :
Code:
INSIDE CONTROL OUTSIDE
Def Enum --------->Sees Enum
+------------------------+
|Public Function as Enum |--->Sees Function
+------------------------+
-
I'm confused...
Do you mean remove the enum definition to global module? I tried defining enum at global module, as public enum. I still get the same error when I try to reference it in the user control.
But if the enum is defined as public in another user control B, defining public property in user control A has no problem! (???)
-
:D
It seems like you've defined your Enums in a module?
Simple reason: anything declared in a module is Private level.
What you have to do is define the enum IN THE usercontrol and you won't have that error. That is why last time VB refused;) to let me define an object WITHEVENTS in a module.
Otherwise, there might be another way around. Try asking Megatron or HeSaidJoe or another Guru. :sad:
-
Stupid me, I forgot to explain clearly.
What it means is that USERCONTROLS and FORMS and even CLASSES are Public, but modules are defined in msvbvm60.dll to be a private type. They are made for API and C++ Dll Functions or some other common functions.
Yes, another USERCTL would work because it is a public-level class (Remember, they are Class Modules with a GUI).
-
Oh, yes...
and a PUBLIC PROPERTY is publicly used EVEN outside this project, so you can't do it...you have to be inside the project in order to use it...
:( Microsoft needs to make it better... :(
-
Thanx!
Thanks for the help,
I didn't know this either... now everything seems to be working better! :p