10181.html
来自「VB技巧问答10000例 VB技巧问答10000例」· HTML 代码 · 共 26 行
HTML
26 行
<html>
<head>
<title>Enum 宣告在 Modual 时, 可否当成 Property 的传回值</title>
</head>
<body bgcolor="#FFFFFF" vlink="#808080">
<center>
<h1>Enum 宣告在 Modual 时, 可否当成 Property 的传回值</h1>
</center>
<hr size=7 width=75%>
<hr size=7 width=75%><p>
Posted by <a href="mailto:sephiroth@optimasoft.com.tw">Apocalypse</a> on February 19, 1999 at 19:20:28:<p>
例如:<br>Modual1.bas<p>Public Enum emAlign<br> emAlignNone=0<br> emAlignTop<br> emAlignBottom<br> emAlignLeft<br> emAlignRight<br> emAlignFillContainer<br>End Enum<p>...<p>Usercontrol1.ctl<p>Private menuAlign As emAlign<p>Public Property Get Align() As emAlign<br> Align = menuAlign<br>End Property<p>.....<p>Compile 时, 会发生 Enum 为 Private 的错误.<br>但若将 Enum 宣告移到 Usercontrol.ctl 则无<br>此问题. <p>请问有人知道原因吗?<p>引述一段 MSDN 中的说明:<p>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.<p>看不出可回答我问题的地方?<br>
<br>
<br><hr size=7 width=75%><p>
<a name="followups">Follow Ups:</a><br>
<ul><!--insert: 10181-->
<!--top: 10238--><li><a href="10238.html">不行</a> <b>小吴</b> <i>17:36:58 2/22/99</i>
(<!--responses: 10238-->0)
<ul><!--insert: 10238-->
</ul><!--end: 10238-->
</ul><!--end: 10181-->
<br><hr size=7 width=75%><p>
</body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?