Solved

copying objects

Posted on 1999-01-15
4
142 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Computer crashes, following error message in event manager 5 198
Microsoft Access combo box help 2 46
Add a task in Outlook from access 11 39
Excel Automation VBA 19 70
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…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

770 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