Visual Basic Classic
--
Questions
--
Followers
Top Experts
clsRequest
|---strX
|---strY
|---strZ
|---Tests
|---strA
|---strB
|---ExtractVariables
|---strC
|---strD
|---FormData
|---strE
|---strF
In my program, I would like to be able to duplicate an existing Request object tree and create a new one which is independent from the first.
At the moment, I have been able to make an exact duplicate of the original using the following code
Dim objNewMember as clsRequest
Set objNewMember = objRequest
although this makes only a pointer to the original object tree. If a change is made to one, it affects the other too.
I have also tried making a new object tree from scratch and copying all the elements across one by one like so:
Dim objNewMember as clsRequest
Set objNewMember = New clsRequest
With objNewMember
.strX = objRequest.strX
.strY = objRequest.strY
.Tests = objRequest.Tests
.ExtractVariables = objRequest.ExtractVariable
.FormData = objRequest.FormData
End With
This seems to work OK with the properties of the objNewMember object but the objects don't get copied across properly and so if a change is made in the Tests object of either original or new object then it will affect both.
Does anyone have any ideas how to do this?
Thanks in advance
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
All deep copying means is that you copy the contents of objects rather than the reference to the object - just as you're doing above.
e.g.
'shallow copy a and b point to same object
set a=b
'full deep copy, b becomes a clone of a, and b's objmember becomes a clone of a's objmember
set b=new Class1
b.member1=a.member1
b.member2=a.member2
set b.objmember=new Class2
b.objmember.memberA=a.objm






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Write a similar method to Fill() a new instance of an object, i.e. which takes an XML file and populates the object.
in 30 minutes i will send

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
1)Change TreeViewCtrl properies Index from 'blank' to 0
2)Change all previous using of your TreeView (for example)
FROM
set MyNode=MyTreeViewName.Node
TO
set MyNode=MyTreeViewName(0).N
3)If you want to copy your treeview, make the following:
Load MyTreeViewName(1)
MyTreeViewName(1).Top = 1500 /* for example */
MyTreeViewName(1).Left = 1500 /* for example */
MyTreeViewName(1).Visible = True
P.S.:
Apreare some problem - open all lists (it's necessary find a properties for blocking it.)
I was meaning an object which consists of pointers to other objects and member variables.
Sorry
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:
Accept andyclap's comment(s) as an answer.
GraemeScotland, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you. DO NOT accept this comment as an answer.
EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Visual Basic Classic
--
Questions
--
Followers
Top Experts
Visual Basic is Microsoft’s event-driven programming language and integrated development environment (IDE) for its Component Object Model (COM) programming model. It is relatively easy to learn and use because of its graphical development features and BASIC heritage. It has been replaced with VB.NET, and is very similar to VBA (Visual Basic for Applications), the programming language for the Microsoft Office product line.