473,748 Members | 4,804 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Nouveautés de VB2008

Bonjour.

N'y aurait-il pas depuis la VB8 un moyen d'assigner en une seule instruction
l'ensemble des propriétés d'un objet aux propriétés de mêmes noms d'un autre
objet, plutôt que d'écrire la liste fastidieuse :

O2.P1 = O1.P1
O2.P2 = O1.P2
O3.P2 = O1.P3
etc.

Une sorte de MOVE CORRESPONDING en COBOL en quelque sorte.

Il me semble avoir entendu parler de quelque chose de semblable lors d'une
présentation de LINQ, mais le souvenir est trop vague.

Merci de votre aide,
Gilbert
Aug 29 '08 #1
10 1188
On Aug 29, 9:19*am, "Gilbert Tordeur" <gilbert.tord.. .@orange.fr>
wrote:
Bonjour.

N'y aurait-il pas depuis la VB8 un moyen d'assigner en une seule instruction
l'ensemble des propriétés d'un objet aux propriétés de mêmes noms d'un autre
objet, plutôt que d'écrire la liste fastidieuse :

O2.P1 = O1.P1
O2.P2 = O1.P2
O3.P2 = O1.P3
etc.

Une sorte de MOVE CORRESPONDING en COBOL en quelque sorte.

Il me semble avoir entendu parler de quelque chose de semblable lors d'une
présentation de LINQ, mais le souvenir est trop vague.

Merci de votre aide,
Gilbert
English please?

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
Aug 29 '08 #2
Sorry, in English :

Hello,
Is there a way since VB2008 to assign with only one statement all the
properties of an object to the (same name) properties of another object,
instead of coding number of trivial lines like
O2.P1 = O1.P1
O2.P2 = O1.P2
O2.P3 = O1.P3
etc.
Something like a MOVE CORRESPONDING in COBOL.

I think I have heard somethink like this in a LINQ meeting sometime ago, but
I do not remember. Thank you for your help.
Gilbert
Aug 29 '08 #3
On Aug 29, 9:38*am, "Gilbert Tordeur" <gilbert.tord.. .@orange.fr>
wrote:
Sorry, in English :

Hello,
Is there a way since VB2008 to assign with only one statement all the
properties of an object to the (same name) properties of another object,
instead of coding number of trivial lines like
O2.P1 = O1.P1
O2.P2 = O1.P2
O2.P3 = O1.P3
etc.

Something like a MOVE CORRESPONDING in COBOL.

I think I have heard somethink like this in a LINQ meeting sometime ago, but
I do not remember. Thank you for your help.
Gilbert
I don't think there is a built in method (I could be wrong).

Once upon a time I wrote a piece using Reflection that did this, but
I'm not sure where that code is. Basically you do a GetProperties on
the source class and then you attempt to do a set value for each of
the properties in the destination class, not the cleanest solution,
but it works.

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
Aug 29 '08 #4
OK, I think I can do that.
Thank you,
Gilbert

"rowe_newsgroup s" <ro********@yah oo.coma écrit dans le message de news:
b7************* *************** **...legroup s.com...
On Aug 29, 9:38 am, "Gilbert Tordeur" <gilbert.tord.. .@orange.fr>
wrote:
Sorry, in English :

Hello,
Is there a way since VB2008 to assign with only one statement all the
properties of an object to the (same name) properties of another object,
instead of coding number of trivial lines like
O2.P1 = O1.P1
O2.P2 = O1.P2
O2.P3 = O1.P3
etc.

Something like a MOVE CORRESPONDING in COBOL.

I think I have heard somethink like this in a LINQ meeting sometime ago,
but
I do not remember. Thank you for your help.
Gilbert
I don't think there is a built in method (I could be wrong).

Once upon a time I wrote a piece using Reflection that did this, but
I'm not sure where that code is. Basically you do a GetProperties on
the source class and then you attempt to do a set value for each of
the properties in the destination class, not the cleanest solution,
but it works.

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
Aug 29 '08 #5
On Aug 29, 10:05*am, "Gilbert Tordeur" <gilbert.tord.. .@orange.fr>
wrote:
OK, I think I can do that.
Thank you,
Gilbert

"rowe_newsgroup s" <rowe_em...@yah oo.coma écrit dans le message de news:
b736454f-7fbb-420d-b62e-432caf702...@k3 0g2000hse.googl egroups.com...
On Aug 29, 9:38 am, "Gilbert Tordeur" <gilbert.tord.. .@orange.fr>
wrote:
Sorry, in English :
Hello,
Is there a way since VB2008 to assign with only one statement all the
properties of an object to the (same name) properties of another object,
instead of coding number of trivial lines like
O2.P1 = O1.P1
O2.P2 = O1.P2
O2.P3 = O1.P3
etc.
Something like a MOVE CORRESPONDING in COBOL.
I think I have heard somethink like this in a LINQ meeting sometime ago,
but
I do not remember. Thank you for your help.
Gilbert

I don't think there is a built in method (I could be wrong).

Once upon a time I wrote a piece using Reflection that did this, but
I'm not sure where that code is. Basically you do a GetProperties on
the source class and then you attempt to do a set value for each of
the properties in the destination class, not the cleanest solution,
but it works.

Thanks,

Seth Rowe [MVP]http://sethrowe.blogsp ot.com/
I just threw some code onto my blog that should do this. As a warning
it's completely untested!

http://sethrowe.blogspot.com/2008/08...ing-class.html

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
Aug 29 '08 #6
Gilbert Tordeur wrote:
Is there a way since VB2008 to assign with only one statement all the
properties of an object to the (same name) properties of another
object, instead of coding number of trivial lines like
>O2.P1 = O1.P1
O2.P2 = O1.P2
O2.P3 = O1.P3
etc.
I could be getting the wrong idea, but isn't that what .Clone is for?

Andrew
Aug 29 '08 #7
On Aug 29, 10:33*am, "Andrew Morton" <a...@in-press.co.uk.inv alid>
wrote:
Gilbert Tordeur wrote:
Is there a way since VB2008 to assign with only one statement all the
properties of an object to the (same name) properties of another
object, instead of coding number of trivial lines like
O2.P1 = O1.P1
O2.P2 = O1.P2
O2.P3 = O1.P3
etc.

I could be getting the wrong idea, but isn't that what .Clone is for?

Andrew
Clone doesn't work if you want to change class types (which is what I
took as what the OP was looking for). It also will only work with the
class implements ICloneable.

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
Aug 29 '08 #8
Andrew,
I think .Clone is for the same class, but if you copy to an object of
another class ?
Regards,
Gilbert
"Andrew Morton" <ak*@in-press.co.uk.inv alida écrit dans le message de
news: 6h************@ mid.individual. net...
Gilbert Tordeur wrote:
>Is there a way since VB2008 to assign with only one statement all the
properties of an object to the (same name) properties of another
object, instead of coding number of trivial lines like
>>O2.P1 = O1.P1
O2.P2 = O1.P2
O2.P3 = O1.P3
etc.

I could be getting the wrong idea, but isn't that what .Clone is for?

Andrew

Aug 29 '08 #9
OK, I got it. I will try and let you know.
Regards,
Gilbert

"rowe_newsgroup s" <ro********@yah oo.coma écrit dans le message de news:
c5************* *************** **...legroups .com...
On Aug 29, 10:05 am, "Gilbert Tordeur" <gilbert.tord.. .@orange.fr>
wrote:
OK, I think I can do that.
Thank you,
Gilbert

"rowe_newsgroup s" <rowe_em...@yah oo.coma écrit dans le message de news:
b736454f-7fbb-420d-b62e-432caf702...@k3 0g2000hse.googl egroups.com...
On Aug 29, 9:38 am, "Gilbert Tordeur" <gilbert.tord.. .@orange.fr>
wrote:
Sorry, in English :
Hello,
Is there a way since VB2008 to assign with only one statement all the
properties of an object to the (same name) properties of another object,
instead of coding number of trivial lines like
O2.P1 = O1.P1
O2.P2 = O1.P2
O2.P3 = O1.P3
etc.
Something like a MOVE CORRESPONDING in COBOL.
I think I have heard somethink like this in a LINQ meeting sometime ago,
but
I do not remember. Thank you for your help.
Gilbert

I don't think there is a built in method (I could be wrong).

Once upon a time I wrote a piece using Reflection that did this, but
I'm not sure where that code is. Basically you do a GetProperties on
the source class and then you attempt to do a set value for each of
the properties in the destination class, not the cleanest solution,
but it works.

Thanks,

Seth Rowe [MVP]http://sethrowe.blogsp ot.com/
I just threw some code onto my blog that should do this. As a warning
it's completely untested!

http://sethrowe.blogspot.com/2008/08...ing-class.html

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
Aug 29 '08 #10

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

Similar topics

7
2538
by: Arthur Dent | last post by:
Does anyone know where i can find a decently thorough list of the language changes in VB2008, such as the new If() function? All i can seem to find through search engines, most of the articles all talk about LINQ, with only cursory mention - at best - of any other new features. Thanks in advance, ... Arthur Dent.
2
3442
by: Arthur Dent | last post by:
I am trying to make a VB2008 Express winforms project, and edit the form. However, when i try to open the form, i get this error: ..NET Framework 2.0 update not found. The win32manifest will not be embedded. It considers it a fatal error, and will not let me edit the form, either in code or design view. I have frameworks 1.1, 2.0, 3.5 installed, and all Windows Updates (sans DreamScene).
6
2679
by: Academia | last post by:
I have a computer at home with a (slow) dialup connection and a computer at school with a fast connection. I want to go there (it is not close) and down load Vb2008 express, burn it into a CD, bring it home and install it on my home computer. Someone told me it can't be done. Is there a way of doing that?
8
3212
by: Galen Somerville | last post by:
My graphics involves a lot of line drawings in a short period of time. I have all the graphics in a separate module. I repeatedly get the pixel data from a USB device, draw the requisite traces, get more data, draw traces, etc. The USB appears to take 82 ms between bursts of data. But the drawing is taking 178 ms !!! It's a real time display, like an oscilloscope, whereby I have to blank the
6
4499
by: Scott Gravenhorst | last post by:
Windows XP SP3 My application is set to open a SaveFile dialog when an exit is requested. When I click the app's close button, the save dialog opens, but when I click to change the folder, the exception occurs pointing to FileSaveDialog1.ShowDialog(). The exception also indicates some problem with system.drawing.dll. The exception text is: "Attempted to read or write protected memory. This is often an
9
1195
by: MichaelH | last post by:
Are there any definite advantages of VB2008 over VB2005? Thank in advance. Michael
2
5791
by: John Whitworth | last post by:
Hi, I'm rewriting an old VB6 app of mine in VB2008. All has been going well with calls to winscard.dll, until I needed to send an array of bytes as part of a structure. When using a winscard trace, I can see that the bytes in the array suddenly become nonsense, whereas I know that what I called the DLL with was good. I think I need to do something along the lines of MarshalAs, but I haven't the first clue where to start. Any...
0
1240
by: John Dann | last post by:
Looking to migrate from VB2005 Pro to VB2008. Can anyone suggest/recommend a VB2008 book that highlights the changes from earlier versions of VB.Net (VB2003/2005) rather than describing VB2008 totally from scratch? I suspect that this may be asking too much in that few books will focus exclusively on migrating/upgrading, but there still may be something out there that is written with existing users of VB.Net in mind. I'm obviously looking...
0
8991
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8830
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9544
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9247
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8243
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4606
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2783
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.