在类模块定义了一个
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 已改变

解决方案 »

  1.   

    窗口代码(窗口名form1)
    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)
      

  2.   

    在用户控件如何接收到 Caption 已改变,哪是事件,应定义一个事件!
    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 
      

  3.   

    zzyong00,我只是把代码敲了进去,做个示范,你的类代码更正规一些,事件声明应该与变量声明放在一起,
    触发事件应该放在Let过程中。
      

  4.   

    Dim m_Tabs() As New cls1
    '''''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
      

  5.   

    先谢谢大家我说的控件是usercontorl自定义的控件,我在做控件