D
Dick Watson
I understand that I can't declare a Public array in a class module. The help
says that I can use As Variant property procedures to emulate this. I guess
I vaguely understand what that means, but even that I'd like to find an
example of. More to the point, I want to nest these objects and still be
able to readily access nested member variables. (Example below.)
I would appreciate any thoughts and pointers to examples/techniques of how
to do this in VBA! Thanks in advance!
Code frags:
-----
Attribute VB_Name = "testnest"
Sub testnodes()
Dim objMyNodes(1) As Node
For x = 0 To UBound(objMyNodes)
Set objMyNodes(x) = New Node
objMyNodes(x).varMyData = "some data"
objMyNodes(x).testthis (0)
Next
Rem this kind of deep reference is really what I'm after
MsgBox objMyNodes(0).objMyNodes(1).objMyNodes(2).varMyData
End Sub
-----
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "Node"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Public varMyData As Variant
Rem compiler gags on this; says Arrays cannot be public
Public objMyNodes() As Node
Sub testthis(intDepth)
ReDim objMyNodes(1)
For x = 0 To UBound(objMyNodes)
Set objMyNodes(x) = New Node
If intDepth < 3 Then
objMyNodes(x).testthis (intDepth + 1)
Else
objMyNodes(x).varMyData = "some data " & Rnd(0)
End If
Next
End Sub
says that I can use As Variant property procedures to emulate this. I guess
I vaguely understand what that means, but even that I'd like to find an
example of. More to the point, I want to nest these objects and still be
able to readily access nested member variables. (Example below.)
I would appreciate any thoughts and pointers to examples/techniques of how
to do this in VBA! Thanks in advance!
Code frags:
-----
Attribute VB_Name = "testnest"
Sub testnodes()
Dim objMyNodes(1) As Node
For x = 0 To UBound(objMyNodes)
Set objMyNodes(x) = New Node
objMyNodes(x).varMyData = "some data"
objMyNodes(x).testthis (0)
Next
Rem this kind of deep reference is really what I'm after
MsgBox objMyNodes(0).objMyNodes(1).objMyNodes(2).varMyData
End Sub
-----
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "Node"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Public varMyData As Variant
Rem compiler gags on this; says Arrays cannot be public
Public objMyNodes() As Node
Sub testthis(intDepth)
ReDim objMyNodes(1)
For x = 0 To UBound(objMyNodes)
Set objMyNodes(x) = New Node
If intDepth < 3 Then
objMyNodes(x).testthis (intDepth + 1)
Else
objMyNodes(x).varMyData = "some data " & Rnd(0)
End If
Next
End Sub