刚学Class不久,遇到个问题难以解决,请高手指点不甚感激!!!
程序要怎改才能将Class中的结构传到Form 让MsgBox 秀出值?结构定义一定要写在模块中吗?这样就变成模块和类模块要绑在一起才能使用~
不知道怎样才能写在类模块中~Form直接就可以接收到类模快中的结构~
Form1
程序代码:
Option Explicit Dim QQQ As New Class1 Private Sub Form_Load() Call AAA End Sub Private Sub AAA() QQQ.Run WWW = QQQ.StructA MsgBox WWW.AA.BB.CC End Sub
Module1
程序代码:
Option Explicit Public Type CCC CC As String End Type Public Type BBB BB As CCC End Type Public Type AAA AA As BBB End Type Public WWW As Variant
Class1
程序代码:
Option Explicit Private ABC As AAA Private mvarStructA As Variant Public Sub Run() Call Assign End Sub Public Property Let StructA(ByVal vData As Variant) mvarStructA = vData End Property Public Property Set StructA(ByVal vData As Variant) Set mvarStructA = vData End Property Public Property Get StructA() As Variant If IsObject(mvarStructA) Then Set StructA = mvarStructA Else StructA = mvarStructA End If End Property Private Function Assign() As Boolean ABC.AA.BB.CC = "123" End Function