Solved

copying objects

Posted on 1999-01-15
4
134 Views
Last Modified: 2010-05-03
Please can soemeone help...i have a control on a form and i would like to be able to have an exact replica created when a button is clicked...the control in question is part of a control array....
basically i need to copy an object, clone it in other words..
thankyou very much
0
Comment
Question by:cybermoonlight
4 Comments
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1456586
You probably now how to add a new entry to the control array.
But here is some code

i = ubound(contarray)+1
load contarray(i)
contarray(i).move left,top, width, height
contarray(i).show

0
 
LVL 10

Accepted Solution

by:
caraf_g earned 120 total points
ID: 1456587
You will have to copy each property individually.

Use the load method to create a new element in the control array and then, for each property do:

NewControl.Property = OldControl.Property

This works for all properties that are standard datatypes. For any Object type properties you must copy THEIR properties individually:

NewControl.SomeObjectProperty.Property = OldControl.SomeObjectProperty.Property

Except if such a property is an object property......
and so on.. and so forth..

There is no "single statement" solution for this problem.


0
 
LVL 4

Expert Comment

by:chabaud
ID: 1456588
Your could use the "TypeLib Information" library (TLBINF32.DLL) to make a generic CopyObject function.
Just list all the source object properties, and for each, invokeHook-get from the source object and invokhook-put to the target object.

Use On Error Resume Next to skip read-only, and design-time only properties...


0
 
LVL 2

Author Comment

by:cybermoonlight
ID: 1456589
cheers caraf..shame vb doesn't have a built in function....thankx
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now