描述:
本来是VB的问题,但是那边没有COM子论坛:(
在VB里建立ActiveX DLL工程,里面的类模块不支持Public的常量。
不知怎样才能做到让组件或者组件里面的类对外提供常量?
就像这样:
Set Conn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "...", Conn, adOpenForwardOnly, adLockOptimistic
(VB的代码,但是意思很明了)
上面的adOpenForwardOnly和adLockOptimistic就是两个常量。准确的说,是ADODB.adOpenForwardOnly和ADODB.adLockOptimistic。
怎样在你自己的工程里面实现这种外界能使用的常量?不管是组件提供(像ADODB.adOpenForwardOnly),还是类提供(像rs.CONSTOFCLASS,假设有的话)。
解决方案1:
try to expose public Enum in the class module or make them properties of your class or use type library, see
HOWTO: Create Constants and DLL Declarations in a Type Library
http://support.microsoft.com/default.aspx?kbid=143258