# Enum 宣告在 Modual 时, 可否当成 Property 的传回值

Posted by Apocalypse on February 19, 1999 at 19:20:28:

例如:
Modual1.bas

Public Enum emAlign
emAlignNone=0
emAlignTop
emAlignBottom
emAlignLeft
emAlignRight
emAlignFillContainer
End Enum

...

Usercontrol1.ctl

Private menuAlign As emAlign

Public Property Get Align() As emAlign
Align = menuAlign
End Property

.....

Compile 时, 会发生 Enum 为 Private 的错误.
但若将 Enum 宣告移到 Usercontrol.ctl 则无
此问题.

请问有人知道原因吗?

引述一段 MSDN 中的说明:

An Enum statement can appear only atmodule level. Once the Enum type is defined, it can be used to declare variables, parameters, orprocedures returning its type. You can't qualify an Enum type name with a module name. Public Enum types in aclass module are not members of the class; however, they are written to thetype library. Enum types defined instandard modules aren’t written to type libraries. Public Enum types of the same name can't be defined in both standard modules and class modules, since they share the same name space. When two Enum types in different type libraries have the same name, but different elements, a reference to a variable of the type depends on which type library has higher priority in the References.

看不出可回答我问题的地方?

Follow Ups:

- 不行 小吴 17:36:58 2/22/99 (0)