473,465 Members | 1,489 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to back up an object...

I have a custom class inherited from a third party control.

Within the class, I need to make a backup copy of the class so that I can
change the properties (font size etc) for printing.

So, I'm using code such as...

Dim backup as dmsreport =me
backup.font=newfont
backup.print
etc etc
I was expecting this not to change any of the parameters of my original
object, however I find that "backup" is created simply as a reference to
"me" and therefore "me" contains all the updates I subsequently make to the
backup.

How do I make a copy of the object so that I can work on the copy without
changing the original?

Hope that this makes sense!

Regards
Simon
Nov 21 '05 #1
6 870
What happens if you use the New keyword?
"Simon Verona" <ne**@aphroditeuk.com> wrote in message
news:eo**************@TK2MSFTNGP15.phx.gbl...
I have a custom class inherited from a third party control.

Within the class, I need to make a backup copy of the class so that I can
change the properties (font size etc) for printing.

So, I'm using code such as...

Dim backup as dmsreport =me
backup.font=newfont
backup.print
etc etc
I was expecting this not to change any of the parameters of my original
object, however I find that "backup" is created simply as a reference to
"me" and therefore "me" contains all the updates I subsequently make to
the backup.

How do I make a copy of the object so that I can work on the copy without
changing the original?

Hope that this makes sense!

Regards
Simon

Nov 21 '05 #2
John

I did try splitting the line into :

dim backup as new dmsreport
backup=me

but this seems to have the same affect.

Regards
Simon
"JohnFol" <Ou************@WibbleObbble.Com> wrote in message
news:ah******************@newsfe5-win.ntli.net...
What happens if you use the New keyword?
"Simon Verona" <ne**@aphroditeuk.com> wrote in message
news:eo**************@TK2MSFTNGP15.phx.gbl...
I have a custom class inherited from a third party control.

Within the class, I need to make a backup copy of the class so that I can
change the properties (font size etc) for printing.

So, I'm using code such as...

Dim backup as dmsreport =me
backup.font=newfont
backup.print
etc etc
I was expecting this not to change any of the parameters of my original
object, however I find that "backup" is created simply as a reference to
"me" and therefore "me" contains all the updates I subsequently make to
the backup.

How do I make a copy of the object so that I can work on the copy without
changing the original?

Hope that this makes sense!

Regards
Simon


Nov 21 '05 #3
ok, I created a new form called Form1 with a single button on it,. The code
is as follows

Dim MyCopyForm As New Form1

MyCopyForm.BackColor = BackColor.Bisque

MyCopyForm.Show()

This gives me the copy I was after. I think the problem you are having is
you explicitly set the "copy" to point to the original. Just try

Dim backup as dmsreport
backup.font=newfont
backup.print


"Simon Verona" <ne**@aphroditeuk.com> wrote in message
news:OZ**************@TK2MSFTNGP14.phx.gbl...
John

I did try splitting the line into :

dim backup as new dmsreport
backup=me

but this seems to have the same affect.

Regards
Simon
"JohnFol" <Ou************@WibbleObbble.Com> wrote in message
news:ah******************@newsfe5-win.ntli.net...
What happens if you use the New keyword?
"Simon Verona" <ne**@aphroditeuk.com> wrote in message
news:eo**************@TK2MSFTNGP15.phx.gbl...
I have a custom class inherited from a third party control.

Within the class, I need to make a backup copy of the class so that I
can change the properties (font size etc) for printing.

So, I'm using code such as...

Dim backup as dmsreport =me
backup.font=newfont
backup.print
etc etc
I was expecting this not to change any of the parameters of my original
object, however I find that "backup" is created simply as a reference to
"me" and therefore "me" contains all the updates I subsequently make to
the backup.

How do I make a copy of the object so that I can work on the copy
without changing the original?

Hope that this makes sense!

Regards
Simon



Nov 21 '05 #4
Well, I could do that, but I was slightly oversimplifying the problem, I
actually change a number of properties, so I thought I could get away with
saving the whole object rather than each property individually...

Regards
Simon
"JohnFol" <Ou************@WibbleObbble.Com> wrote in message
news:SX*****************@newsfe5-win.ntli.net...
ok, I created a new form called Form1 with a single button on it,. The
code is as follows

Dim MyCopyForm As New Form1

MyCopyForm.BackColor = BackColor.Bisque

MyCopyForm.Show()

This gives me the copy I was after. I think the problem you are having is
you explicitly set the "copy" to point to the original. Just try

Dim backup as dmsreport
backup.font=newfont
backup.print


"Simon Verona" <ne**@aphroditeuk.com> wrote in message
news:OZ**************@TK2MSFTNGP14.phx.gbl...
John

I did try splitting the line into :

dim backup as new dmsreport
backup=me

but this seems to have the same affect.

Regards
Simon
"JohnFol" <Ou************@WibbleObbble.Com> wrote in message
news:ah******************@newsfe5-win.ntli.net...
What happens if you use the New keyword?
"Simon Verona" <ne**@aphroditeuk.com> wrote in message
news:eo**************@TK2MSFTNGP15.phx.gbl...
I have a custom class inherited from a third party control.

Within the class, I need to make a backup copy of the class so that I
can change the properties (font size etc) for printing.

So, I'm using code such as...

Dim backup as dmsreport =me
backup.font=newfont
backup.print
etc etc
I was expecting this not to change any of the parameters of my original
object, however I find that "backup" is created simply as a reference
to "me" and therefore "me" contains all the updates I subsequently make
to the backup.

How do I make a copy of the object so that I can work on the copy
without changing the original?

Hope that this makes sense!

Regards
Simon



Nov 21 '05 #5
If the class is a "roll your own", you can add a Copy Property that uses
"PropertyInfo" to copy all of the properties to a new instance of your class.
If not roll your own, you can create a function to copy all the property
values to a new instance of the class.

"Simon Verona" wrote:
Well, I could do that, but I was slightly oversimplifying the problem, I
actually change a number of properties, so I thought I could get away with
saving the whole object rather than each property individually...

Regards
Simon
"JohnFol" <Ou************@WibbleObbble.Com> wrote in message
news:SX*****************@newsfe5-win.ntli.net...
ok, I created a new form called Form1 with a single button on it,. The
code is as follows

Dim MyCopyForm As New Form1

MyCopyForm.BackColor = BackColor.Bisque

MyCopyForm.Show()

This gives me the copy I was after. I think the problem you are having is
you explicitly set the "copy" to point to the original. Just try

Dim backup as dmsreport
backup.font=newfont
backup.print


"Simon Verona" <ne**@aphroditeuk.com> wrote in message
news:OZ**************@TK2MSFTNGP14.phx.gbl...
John

I did try splitting the line into :

dim backup as new dmsreport
backup=me

but this seems to have the same affect.

Regards
Simon
"JohnFol" <Ou************@WibbleObbble.Com> wrote in message
news:ah******************@newsfe5-win.ntli.net...
What happens if you use the New keyword?
"Simon Verona" <ne**@aphroditeuk.com> wrote in message
news:eo**************@TK2MSFTNGP15.phx.gbl...
>I have a custom class inherited from a third party control.
>
> Within the class, I need to make a backup copy of the class so that I
> can change the properties (font size etc) for printing.
>
> So, I'm using code such as...
>
> Dim backup as dmsreport =me
> backup.font=newfont
> backup.print
> etc etc
>
>
> I was expecting this not to change any of the parameters of my original
> object, however I find that "backup" is created simply as a reference
> to "me" and therefore "me" contains all the updates I subsequently make
> to the backup.
>
> How do I make a copy of the object so that I can work on the copy
> without changing the original?
>
> Hope that this makes sense!
>
> Regards
> Simon
>



Nov 21 '05 #6
Thanks, I'll have to do that.

Regards
Simon
"Dennis" <De****@discussions.microsoft.com> wrote in message
news:13**********************************@microsof t.com...
If the class is a "roll your own", you can add a Copy Property that uses
"PropertyInfo" to copy all of the properties to a new instance of your
class.
If not roll your own, you can create a function to copy all the property
values to a new instance of the class.

"Simon Verona" wrote:
Well, I could do that, but I was slightly oversimplifying the problem, I
actually change a number of properties, so I thought I could get away
with
saving the whole object rather than each property individually...

Regards
Simon
"JohnFol" <Ou************@WibbleObbble.Com> wrote in message
news:SX*****************@newsfe5-win.ntli.net...
> ok, I created a new form called Form1 with a single button on it,. The
> code is as follows
>
> Dim MyCopyForm As New Form1
>
> MyCopyForm.BackColor = BackColor.Bisque
>
> MyCopyForm.Show()
>
>
>
> This gives me the copy I was after. I think the problem you are having
> is
> you explicitly set the "copy" to point to the original. Just try
>
> Dim backup as dmsreport
> backup.font=newfont
> backup.print
>
>
>
>
>
>
>
>
> "Simon Verona" <ne**@aphroditeuk.com> wrote in message
> news:OZ**************@TK2MSFTNGP14.phx.gbl...
>> John
>>
>> I did try splitting the line into :
>>
>> dim backup as new dmsreport
>> backup=me
>>
>> but this seems to have the same affect.
>>
>> Regards
>> Simon
>> "JohnFol" <Ou************@WibbleObbble.Com> wrote in message
>> news:ah******************@newsfe5-win.ntli.net...
>>> What happens if you use the New keyword?
>>>
>>>
>>> "Simon Verona" <ne**@aphroditeuk.com> wrote in message
>>> news:eo**************@TK2MSFTNGP15.phx.gbl...
>>>>I have a custom class inherited from a third party control.
>>>>
>>>> Within the class, I need to make a backup copy of the class so that
>>>> I
>>>> can change the properties (font size etc) for printing.
>>>>
>>>> So, I'm using code such as...
>>>>
>>>> Dim backup as dmsreport =me
>>>> backup.font=newfont
>>>> backup.print
>>>> etc etc
>>>>
>>>>
>>>> I was expecting this not to change any of the parameters of my
>>>> original
>>>> object, however I find that "backup" is created simply as a
>>>> reference
>>>> to "me" and therefore "me" contains all the updates I subsequently
>>>> make
>>>> to the backup.
>>>>
>>>> How do I make a copy of the object so that I can work on the copy
>>>> without changing the original?
>>>>
>>>> Hope that this makes sense!
>>>>
>>>> Regards
>>>> Simon
>>>>
>>>
>>>
>>
>>
>
>


Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: lawrence | last post by:
I've been bad about documentation so far but I'm going to try to be better. I've mostly worked alone so I'm the only one, so far, who's suffered from my bad habits. But I'd like other programmers...
9
by: jcnews | last post by:
When designing a webpage, is there a way to disable the back button? It must be possible. I am asking because there are certain web applications that I have used that require the user to...
5
by: Mark Overstreet | last post by:
I am writing an app that needs to contain an object model that allows it to be controlled similiar to something like Word. However, I am writing this in C# and all managed code. I know that I can...
2
by: VinDotNet | last post by:
Here's the Scenario I am facing: I've got a winform managed c++ client which connects to my managed COM+ server application (by making createinstance, then typecasting the object to an interface,...
29
by: Tom wilson | last post by:
I can't believe this is such an impossibility... I have an asp.net page. It accepts data through on form fields and includes a submit button. The page loads up and you fill out some stuff. ...
7
by: klynn | last post by:
I'm wondering what the best way to do the following: I have a page with a table. I built a custom class that creates a System.Web.UI.WebControls table object and return it to the webpage as a...
4
by: Alan Wang | last post by:
Hi there, I am having a problem with my asp.net web pages. If user hit BACK button on IE and then click some other web controls on the web page. the page goes to blank page. Anyone has the...
3
by: Brian Henry | last post by:
If i have a structure type and i place the structures data into a tag property (which is an object) it will go in obviously, but when i pull an object back into a structrured type it will error.....
2
by: Bill Gower | last post by:
I have a form that displays a list of items. The user can either click on a button called "New" to create a new item or double click on a row in the list to edit that item. An edit form is...
0
by: sweatha | last post by:
Hello Friends I have created the project with 2 forms. In the first form, I have 2 buttons. The first button has the backcolor as "fusia" by default. If I click the button means then backcolor of...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.