在类模块定义了一个
Private sCaption As StringPublic Property Get Caption() As String
Caption = sCaption
End PropertyPublic Property Let Caption(ByVal New_Caption As String)
sCaption = New_Caption
End Property在用户控件如何接收到 Caption 已改变
Private sCaption As StringPublic Property Get Caption() As String
Caption = sCaption
End PropertyPublic Property Let Caption(ByVal New_Caption As String)
sCaption = New_Caption
End Property在用户控件如何接收到 Caption 已改变
Dim WithEvents mycls As cls1Private Sub Command1_Click()
Set mycls = New cls1
mycls.Caption = "ggg"
End SubPrivate Sub mycls_txtchang(strmy As String)
'在此处处理类性质改变事件
End Sub
类代码(类名cls1)
Private sCaption As StringPublic Property Get Caption() As String
Caption = sCaption
RaiseEvent txtchang(Caption)
End PropertyPublic Property Let Caption(ByVal New_Caption As String)
sCaption = New_Caption
End PropertyPublic Event txtchang(strmy As String)
Private sCaption As String
public event CaptionChange()'定义一个事件
Public Property Get Caption() As String
Caption = sCaption
End Property Public Property Let Caption(ByVal New_Caption As String)
sCaption = New_Caption
raiseevent CaptionChange '当caption改变时抛出事件
End Property
触发事件应该放在Let过程中。
'''''Dim WithEvents m_Tabs() As cls1''''数组不能定义Public Property Get Tabs(ByVal Index As Integer) As cls1
Set Tabs = m_Tabs(Index)
End PropertyPublic Property Let Tabs(ByVal Index As Integer, ByVal New_Tabs As cls1)
Set m_Tabs(Index) = New_Tabs
'我在要接收到改变的东西
End Property我想输入tabs.caption="jjjj"就能接收到以下是我的class
Private sCaption As String
Public Enabled As Boolean
Public Visible As Boolean
Public Icon As IPictureDisp
Public Index As Integer
Public Event CaptionChange(myCaption As String)Public Property Get Caption() As String
Caption = sCaption
End PropertyPublic Property Let Caption(ByVal New_Caption As String)
sCaption = New_Caption
RaiseEvent CaptionChange(sCaption)
End Property