Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Self-referencing in a class subroutine ("Me" is not working) 2

Status
Not open for further replies.

Krypta

Programmer
Feb 22, 2011
2
US
I am trying to build a tree class. Here is the relevant code from the class CNode:

Private pChildA As CNode
Private pParentA As CNode

Public Property Get childA() As CNode
child = pChildA
End Property

Public Property Set childA(inChild As CNode)
Set pChildA = inChild
End Property

Public Property Get parentA() As CNode
parentA = pParentA
End Property

Public Property Set parentA(inParentA As CNode)
Set pParentA = inParentA
End Property

Public Sub testing(x As CNode)
Set Me.parentA = x
Dim tempNode
Set tempNode = Me.parentA
Set tempNode.childA = Me
End Sub



***********************************************

In a module, I have the following subroutine:

Sub test()
Dim nodeA As CNode, nodeC As CNode
Set nodeA = New CNode

Set nodeC = New CNode
Call nodeA.testing(nodeC)


End Sub

**************************

When I run this I get Run-time error '91': Object variable or With block variable not set.

Can anyone help me?
 
The childA property:
Code:
Public Property Get childA() As CNode
    [!]Set[/!] child[!]A[/!] = pChildA
End Property

combo
 
Thank you - that did the trick.
Is there a setting in the debugger that will let me see which line in class module is causing the error? That would help me figure out problems like this in the future.
 
Option Explicit

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
In the VBE, Tools > Options > General tab. Choose either "break on all errors" or "break in class modules", then you can choose "Debug" when you get the error and see the line it's on.

Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top