|
-
Sep 17th, 2000, 10:19 PM
#1
Thread Starter
Lively Member
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.
-
Sep 17th, 2000, 11:01 PM
#2
Hyperactive Member
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
+------------------------+
-
Sep 17th, 2000, 11:13 PM
#3
Thread Starter
Lively Member
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! (???)
-
Sep 17th, 2000, 11:17 PM
#4

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:
-
Sep 17th, 2000, 11:23 PM
#5
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).
-
Sep 17th, 2000, 11:28 PM
#6
-
Apr 15th, 2002, 03:11 AM
#7
New Member
Thanx!
Thanks for the help,
I didn't know this either... now everything seems to be working better!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|