在ActiveDll中  MyDll.cls摸块中的代码如下:Private mstrPath As String '局部复制
Public Sub Preview()
MainForm.Show vbModal '模式显示0
End Sub
Public Property Let MainPath(ByVal vData As String)
'向属性指派值时使用,位于赋值语句的左边。
    mstrPath = vData
End Property
Public Property Get MainPath() As String
'检索属性值时使用,位于赋值语句的右边。
    MainPath = mstrPath
End Property在ActiveDll中 Mainform.frm窗口摸块中的代码如下:
Private Sub Form_Load()
MsgBox MainPath
End Sub主程序中
   Dim xmaint As New MyDll
       xmaint.MainPath = "test" '将Mainpath属性赋值
       'MsgBox xmaint.MainPath
       xmaint.Preview结果dll中msgbox显示 mainpath的属性值是空, 但如果msgbox放在cls模快中mainpath的属性值 ="test",怎么回事?就是说在Dll中的窗口模块中怎么调用类模快中的属性?

解决方案 »

  1.   

    窗体也是类,MyDll.cls也是类,两个类怎么能互相访问对方的私有变量啊!你可以在窗体中申明一个属性,MainPath,然后在MyDll.cls的Preview方法中,
    显示窗体之前设置这个属性就行了
      

  2.   

    这么着吧...你给MainForm添加一个方法:
    Public Sub ShowPath(ByVal sPath As String)
        ' 记录sPath供Form_Load()中访问
        m_sPath = sPath  ' m_sPath为模块级私有变量    Call Me.Show(vbModal)
    End Sub
      

  3.   

    这不对呀,我就是要在mainform中访问cls中的属性
      

  4.   

    这么个简单的问题,居然没人回答,csdn是怎么回事?是人都冷漠了?还是嫌分不够.没人谈论这问题的话,中午结帐
      

  5.   

    为什么一定要访问cls的属性呢?实现不久行了么?或者还有其他功能要实现的?
    那就改成这样吧:MainForm添加一个方法:
    Public Sub ShowPath(ByVal oMyDll As CMyDll)
        ' 记录MainPath供Form_Load()中访问
        m_sPath = oMyDll.MainPath  ' m_sPath为模块级私有变量    Call Me.Show(vbModal)
    End Sub