Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

copying objects

Posted on 1999-01-15
4
Medium Priority
?
170 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 480 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

963 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