?
Solved

copying objects

Posted on 1999-01-15
4
Medium Priority
?
166 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month11 days, left to enroll

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