在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中的窗口模块中怎么调用类模快中的属性?
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中的窗口模块中怎么调用类模快中的属性?
显示窗体之前设置这个属性就行了
Public Sub ShowPath(ByVal sPath As String)
' 记录sPath供Form_Load()中访问
m_sPath = sPath ' m_sPath为模块级私有变量 Call Me.Show(vbModal)
End Sub
那就改成这样吧:MainForm添加一个方法:
Public Sub ShowPath(ByVal oMyDll As CMyDll)
' 记录MainPath供Form_Load()中访问
m_sPath = oMyDll.MainPath ' m_sPath为模块级私有变量 Call Me.Show(vbModal)
End Sub