Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 3rd, 2003, 02:42 AM
shafan's Avatar
shafan shafan is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 123 shafan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 51 m 51 sec
Reputation Power: 7
object reference

Hi,
I have an object in a collection.
I pass it by ref to a form in order to edit it (the form has a local var to hold it).
I also store in the form an un-referenced copy of the object to allow the user canceling the operation (in which case I thought to 'return' the copied un-changed object).
The problem is that when canceling, setting the local referencing variable to the copied unchanged object doesn't affect the original item in the collection - reference issue.
Can I change the reference using AddressOf or ObjPtr (or anything else) so that setting the local referencing variable will do the trick?

thanx

Reply With Quote
  #2  
Old April 3rd, 2003, 02:06 PM
epl epl is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: Dublin
Posts: 413 epl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 18 m 18 sec
Reputation Power: 8
can't you make the changes to the copy of the object - and just apply these (ie copy them to the collection-held / referenced object) once the form has been ok'd.

Reply With Quote
  #3  
Old April 5th, 2003, 10:34 PM
shafan's Avatar
shafan shafan is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 123 shafan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 51 m 51 sec
Reputation Power: 7
That's what I do at the moment, but with objects that have many members it's a lengthy process. I'm looking for a more elegant solution to do the same thing.

Reply With Quote
  #4  
Old April 8th, 2003, 04:06 AM
Wingman Wingman is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Bavaria, Germany
Posts: 140 Wingman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 40 m 41 sec
Reputation Power: 6
What you want is transaction based objects like they're used in MTS components (just like SQL transactions). But i guess that's a overkill ;-))

Normally you apply changes to your object when you click 'OK' or 'Save', any change before is kept in another structure like a String or a Textarea. When the user clicks on OK, the String is set at your object.

If you want to work with your object, then implementing Clone methods could also do the job. When you load your editing form, clone your object and let the form do instant manipulating of your clone. If the user clicks on 'OK', save the clone in your collection at the index of your original object.

Reply With Quote
  #5  
Old April 8th, 2003, 11:43 PM
shafan's Avatar
shafan shafan is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 123 shafan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 51 m 51 sec
Reputation Power: 7
the un-referenced object I mentioned is a clone of the one stored in the collection - there are 2 identical objects in the begining and the changes are done to one of them, but in order to discard the changes it is not enough to do 'Set ChangedObject = ClonedOriginalObject' cause the changes already took place (it's a reference) and the assignment won't undo them.
What I need to do is set the actual place in memory pointing to the changed object so that it would point to the cloned unchanged one.

I think it can be done using CopyMemory but I'm still checking it.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > object reference


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway