As IUnknown是不行的 你可以根据得到的输入判断然后决定是否执行某些功能 Public 肯定是公开的 Private 是私有的 所以答案只有一个:没有
用 #If ... Then #End If来定义你的函数不就可以了,在设计时没有,在运行时有的条件不就隐藏了
怎么得到 Redim 使用的接口?Class1.cls Option ExplicitPrivate B() As BytePublic Property Get mArray() As Byte() Let mArray = B End PropertyPublic Property Let mArray(ByRef vData() As Byte) Let B = vData End PropertyPublic Property Let Item(Index As Long, vData As Byte) B(Index) = vData End PropertyPublic Property Get Item(Index As Long) As Byte Item = B(Index) End PropertyPublic Property Get NewEnum() As IUnknown '本属性允许用 For...Each 语法枚举该数组。 Set NewEnum = B.[_NewEnum] End PropertyPublic Property Get NewRedim() As IUnknown 'IDispatch '用什么返回 Redim 数组时,访问的接口? Set NewRedim = B.[_NewRedim] End PropertyPrivate Sub Class_Terminate() Erase B End Sub Form1.frm Option ExplicitPrivate B() As Byte Private mClass1 As Class1Private Sub Command1_Click() ReDim B(5) B(1) = 250 Set mClass1 = New Class1 mClass1.mArray = B() Dim ele As Variant For Each ele In mClass1.mArray MsgBox ele Next 'ReDim mClass1.mArray(10) '怎么得到 Redim 使用的接口? End Sub
IUnknown是什么,是不是这个意思,代码放在Command1_Click事件里 dim IUn as IUnknown IUn= mClass1.NewRedim
别忘了还有 Friend 呢!
Public Property Get NewEnum() As IUnknown '本属性在用 For...Each 语法枚举该对象属性时,返回一个数组的接口。
你可以根据得到的输入判断然后决定是否执行某些功能
Public 肯定是公开的
Private 是私有的
所以答案只有一个:没有
#If ... Then
#End If来定义你的函数不就可以了,在设计时没有,在运行时有的条件不就隐藏了
Option ExplicitPrivate B() As BytePublic Property Get mArray() As Byte()
Let mArray = B
End PropertyPublic Property Let mArray(ByRef vData() As Byte)
Let B = vData
End PropertyPublic Property Let Item(Index As Long, vData As Byte)
B(Index) = vData
End PropertyPublic Property Get Item(Index As Long) As Byte
Item = B(Index)
End PropertyPublic Property Get NewEnum() As IUnknown
'本属性允许用 For...Each 语法枚举该数组。
Set NewEnum = B.[_NewEnum]
End PropertyPublic Property Get NewRedim() As IUnknown 'IDispatch
'用什么返回 Redim 数组时,访问的接口?
Set NewRedim = B.[_NewRedim]
End PropertyPrivate Sub Class_Terminate()
Erase B
End Sub
Form1.frm
Option ExplicitPrivate B() As Byte
Private mClass1 As Class1Private Sub Command1_Click()
ReDim B(5)
B(1) = 250
Set mClass1 = New Class1
mClass1.mArray = B()
Dim ele As Variant
For Each ele In mClass1.mArray
MsgBox ele
Next
'ReDim mClass1.mArray(10) '怎么得到 Redim 使用的接口?
End Sub
dim IUn as IUnknown
IUn= mClass1.NewRedim
'本属性在用 For...Each 语法枚举该对象属性时,返回一个数组的接口。